Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Jeff Yang
Guest
 
Posts: n/a
#1: Nov 15 '05
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/de...ms06112002.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!



Dmitriy Lapshin [C# / .NET MVP]
Guest
 
Posts: n/a
#2: Nov 15 '05

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


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.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jeff Yang" <derlupy@hotmail.com> wrote in message
news:eA1W$BuuDHA.3496@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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.
>[/color]
http://msdn.microsoft.com/library/de...ms06112002.asp[color=blue]
> 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!
>
>[/color]

Closed Thread