471,328 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,328 software developers and data experts.

Re: deadlock when using waitOne in a STA thread

On Tue, 10 Jun 2008 03:41:27 -0700, Daniel Cuculescu
<dc********@ixiacom.comwrote:
I have the problem described bellow with the calls to WaitHandle.WaitOne
causing re-entrancy on main GUI thread (STA) of a .NET application and I
would like to find out:
- did anybody else run into the same problem?
- is it a known issue? is there a fix for it?
- is there a workaround for it?
- if no fix/workaround I would like to find out the complete list of
messages that are being handled (dispatched by ole32.dll OLE/COM message
pump) when doing WaitOne on a STA thread.
I admit, I wasn't even aware that _any_ message pumping was done when
you're in a managed blocking call, though in hindsight it does make some
sense.

That said, the correct fix for this is IMHO to simply not call WaitOne()
in your main GUI thread. That thread simply should not be blocked by you,
and this is doubly true if you also have code that calls
Control.Invoke(). You simply have a basic architectural bug that you need
to correct.

By the way, you should refrain from posting messages with attachments.
Many people will not even see your message, because most ISPs simply block
Usenet messages with attachments, your messages is unnecessarily reduced
in audience (I believe Google Groups also ignores such messages, as likely
do other archives, which negates one of the most significant benefits of a
forum like this: allowing others to see previously asked questions and
take advantage of them).

Just make sure the code is reasonably short and paste it directly into the
message.

Pete
Jun 27 '08 #1
0 930

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jürgen Devlieghere | last post: by
reply views Thread by Chris Chilvers | last post: by
reply views Thread by Gordon Cone | last post: by
reply views Thread by Gordon Cone | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.