In a WinForms project I have an algorithm running that continually computes data and updates the UI. It looks like this:
async Task BackgroundWorkAsync() {
while (true) {
var result = await Compute();
UpdateUI(result);
}
}
Sometimes, depending on what result
contains I want to show a MessageBox
but continue running the algorithm immediately. The following does not work because it blocks further processing until the MessageBox
is dismissed:
while (true) {
var result = await Compute();
UpdateUI(result);
if (...) MessageBox.Show(...); //new code
}
How can I make the MessageBox.Show
call non-blocking?
(Yes, this means that multiple message boxes might pop up at the same time. That's OK.)