A question about "Safe, Simple Multithreading in Windows Forms, Part 1" on MSDN

  • Thread starter Thread starter Jeff Yang
  • Start date Start date
J

Jeff Yang

These days,I have read the artile "Safe, Simple Multithreading in Windows
Forms, Part 1" on MSDN,and I also runed the example of it.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms06112002.asp
The question is In function void ShowProgress(string pi, int totalDigits,
int digitsSoFar);
if I use Invoke(showProgress, new object[] { pi, totalDigits,
digitsSoFar});the UI performs better(it responses to my minimize&restore
faster),and if I use BeginInvoke(showProgress, new object[] { pi,
totalDigits, digitsSoFar});,then the UI seems performs slower.
why Invoke is better than BeginInvoke?(As generally thinking,BeginInvoke
should be better than Invoke,because it works asynchronously).

thanks!
 
Jeff,

Invoke(...) runs the passed delegate on the UI thread synchronously (that
is, the calling thread will block until the Invoke() call returns).

BeginInvoke(...) returns immediately and schedules the delegate to be run on
the UI thread.
 
Back
Top