Performing a time consuming task inside a WinForm application is better done wrapping it inside another thread.
As Thread.Join()
blocks the main thread is there anything wrong using this kind of approach with Application.DoEvents
?
Thread t = new Thread(() => {...});
t.Start();
while (t.IsAlive) Application.DoEvents();
t.Join();
Edit: I don't want to stop the execution of main thread, in fact I have an IOleMessageFilter
running on the STAThread. This is also the reason why I thought that DoEvents
makes sense.