|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can't WaitHandle.WaitAll in an STAThread ?Just now I translated Jon Skeet's WaitHandle.WaitAny / .WaitAll (<http://yoda.arachsys.com/csharp/threads/waithandles.shtml>) from C# into VB.NET, and after the first go I ran into trouble: (from the docs for WaitHandle.WaitAll) >> NotSupportedException The number of objects in waitHandles is greaterthan the system permits. -or- The current thread is marked with the STAThreadAttribute, and waitHandles contains more than one element. >> After digging a bit, I came to the conclusion that VB.NET apps, evenones that aren't explicitly marked for COM Interop, are STA threaded by default, so a simple application of the MTAThread attribute to my Main method fixed the problem. However, what would I do if I had a real app that *needed* to be STAThread'd, and I wanted to wait for multiple signals? The docs offer no justification, just a blunt Note The WaitAll method is not supported on threads that are marked with STAThreadAttribute. Why not? And what could one do about it? -- Larry Lard Replies to group please
Show quote
Hide quote
"Larry Lard" <larryl***@hotmail.com> wrote in message The reason for this is that "WaitAll" boils down to a call to news:1140086633.475867.152810@o13g2000cwo.googlegroups.com... | [the xpost is justifiable, I think] | | Just now I translated Jon Skeet's WaitHandle.WaitAny / .WaitAll | (<http://yoda.arachsys.com/csharp/threads/waithandles.shtml>) from C# | into VB.NET, and after the first go I ran into trouble: | | (from the docs for WaitHandle.WaitAll) | >> | NotSupportedException The number of objects in waitHandles is greater | than the system permits. | -or- | | The current thread is marked with the STAThreadAttribute, and | waitHandles contains more than one element. | >> | | After digging a bit, I came to the conclusion that VB.NET apps, even | ones that aren't explicitly marked for COM Interop, are STA threaded by | default, so a simple application of the MTAThread attribute to my Main | method fixed the problem. | | However, what would I do if I had a real app that *needed* to be | STAThread'd, and I wanted to wait for multiple signals? The docs offer | no justification, just a blunt | | Note The WaitAll method is not supported on threads that are marked | with STAThreadAttribute. | | Why not? And what could one do about it? | | -- | Larry Lard | Replies to group please | "MsgWaitFormultipleObjects" Win32 API with bWaitAll set to TRUE. This would deadlock when it was allowed to be called from a thread that creates windows (like an STA thread does). Please check msdn to get more info on the semantics of MsgWaitFormultipleObjects, especially the remarks are enlightening. Willy.
How is it possible ...
Edanmo Shell Extension: How to Install it? Unmanaged DLL Callback - Program Unexpectedly Quits Carriage Return and Line Feed Syntax need help reading contents of a file into an array...SKYPE ME. tab function in a multiline text box Transparent splash screen Moving Rectangle within a PictureBox Control Interface creation in VB.Net 2005 Determine disabled status |
|||||||||||||||||||||||