Using the .NET 4 Task library to display a blocking message box in WPF
问题 I have the following code in my WPF application: Task task = Task.Factory.StartNew(() => { DoInitialProcess(); }); task.ContinueWith(t => Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Error: " + t.Exception.InnerExceptions[0].Message); })), TaskContinuationOptions.OnlyOnFaulted); It successfully triggers the continuation and displays the message box if an exception occurs, but it does not block input on the main UI thread. Why doesn't it block the main UI thread, and what is the