Re: cross-thread UI updating?
- From: Mehdi <vioccc@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 May 2007 14:20:14 +0100
On Wed, 23 May 2007 23:41:22 +0200, Tim Van Wassenhove wrote:
// call this method again, but on the ui thread...
this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
Just a point of detail here. this.EndInvoke(this.BeginInvoke()) is
unecessarily complicated.
If you want the worker thread to block until the method invoked in the UI
thread has completed (which is what you do by calling
this.EndInvoke(this.BeingInvoke())), simply call this.Invoke() (where this
represents a Control). No need for BeginInvoke / EndInvoke here. Note that
using Control.Invoke can lead to some very subtle dead-locks if you are
sharing data protected by locks between the worker thread and the UI
thread.
If you want the worker thread to invoke a method in the UI thread but not
wait for its completion before continuing its job, simply call
this.BeginInvoke() (where this represents a Control). There is no need to
call Control.EndInvoke() (this is the only case in the .NET standard Class
Library in which the call to EndInvoke() after a BeginInvoke() is not
required).
.
- Follow-Ups:
- Re: cross-thread UI updating?
- From: spacemarine
- Re: cross-thread UI updating?
- References:
- cross-thread UI updating?
- From: spacemarine
- Re: cross-thread UI updating?
- From: Tim Van Wassenhove
- cross-thread UI updating?
- Prev by Date: Dynamic Control Example for 2.0?
- Next by Date: Re: Dynamic Control Example for 2.0?
- Previous by thread: Re: cross-thread UI updating?
- Next by thread: Re: cross-thread UI updating?
- Index(es):
Relevant Pages
|