Re: Simple race condition that I can't solve.



I wrote:

> Weird -- if I use BeginInvoke instead of Invoke, it completes without error
> (tried it about 20 times). If I change that back to Invoke, I get an error
> every time.
>
> Weirder -- when I use BeginInvoke, I don't even have to test /closed/. I
> can remove the /if (!closed)/ statement and *still* I don't get any errors.
>
> Hmm...

Okay -- it appears that HandleFinished() doesn't run when I use
BeginInvoke() (tested by putting a breakpoint in HandleFinished and seeing
that the breakpoint never gets hit) -- so that could explain the above.

But I'm just confused totally now.
.



Relevant Pages

  • Re: Populate an ImageList from another thread
    ... The improvement on the GUI thread comes at a significant cost to the worker thread. ... That said, since you've proved that this is _not_ a deadlock problem, I think it's a good time now to revisit Greg's suggestion, which is to use BeginInvoke() instead of Invoke. ... I don't feel that using BeginInvokeis a proper technique for specifically avoiding deadlock. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem with the ListBox
    ... The Windows UI is not thread safe (not a .Net limitation, ... members of your form (actually, they are members of Control, and anything ... InvokeRequired, and BeginInvoke() ... BeginInvoke, and an Invoke method. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Ruthlessly killing a BackgroundWorker thread
    ... The alternative is of course to pass a cancel flag to all of the computation methods and have them look at it periodically and bail out if it's true. ... How can I find out when the RichTextBox has actually scrolled to the bottom of the input, or better yet, clear the queue of things that have been sent to it with BeginInvoke? ... The latter especially requires additional synchronization between threads, to ensure that you only ignore invoked updates up to some point, rather than indefinitely. ... Switching to Invoke() took care of it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: invoke vs begininvoke, mdi/child and showdialog
    ... The reason Invoke works is that the call to Invoke waits until the call is ... Switching to UI thread using Invoke, ... Switching to UI thread using BeginInvoke(), ... syncronous with the other child windows. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: cross-thread operation
    ... Simple; the spawned thread cannot talk to the TextBox directly; you need to ... Note that BeginInvoke will run in parallel, ... can use Invoke to run in series, but this can cause issues if the UI thread ... logical updates in a single UI update, ...
    (microsoft.public.dotnet.languages.csharp)