Re: multiple threads writing to WebBrowser, getting deadlocked
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Tue, 3 Apr 2007 19:59:00 +0100
Zytan <zytanlithium@xxxxxxxxx> wrote:
<snip>
For the curious:
Move the Thread.Sleep(400) to AFTER the MyWrite call, and it works,
always. Thanks to Jon's great reply, I now know why. This single
difference was the difference between two identical apps I made, and I
was dumbfounded as to why one worked and the other didn't.
Thread.Sleep() at the end doesn't give the deadlock of Control.Invoke
and Thread.Join to occur.
Hmm. You've still got a potential deadlock, unfortunately.
If you click the stop button at just the wrong time, it will still
break. You can end up with btnStop_Click running, waiting for myThread
to finish - but with myThread waiting for a call to web.Invoke to
finish.
Using BeginInvoke is certainly a reasonable way of avoiding this,
although I'd avoid calling Thread.Join in the UI thread too.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- References:
- Prev by Date: Re: Total confused and need help with small encryption and decryption methods
- Next by Date: Re: detecting the (brute) disconnection of a client
- Previous by thread: Re: multiple threads writing to WebBrowser, getting deadlocked
- Next by thread: Re: multiple threads writing to WebBrowser, getting deadlocked
- Index(es):
Loading