You can't use WaitAll on an STA thread (i.e. the main thread. Almost all .NET programs need to have the main thread STA--a COM requirement to ensure the main COM message pump does not get blocked).
You can use WaitAll on any background thread (ensuring it's MTA, of course- -which it can be) which then toggles a synchronization object that can be tested with WaitOne in the main thread. This is a common method of getting around this problem. This issue has been discussed a few times in the past on this list, likely with usable solutions. Also, I believe Irena Kennedy has a blog post [1] that shows how to implement something like that. [1] http://blogs.msdn.com/irenak/archive/2006/04/06/569806.aspx On Wed, 7 Feb 2007 11:16:55 -0500, Andy Smith <[EMAIL PROTECTED]> wrote: >Hi - > >I'm having a problem that I'm hoping folks here can help with. It involves >COM issues as well as .NET, so please let me know if there's a better list >to be posting this to.... > >I'm working on a console app (in C#) that is calling into a COM API >(Virtual Server 2005) that requires the COM security level >of 'Impersonate'. To accomplish that I'm calling CoInitializeSecurity() >and it works, but only if I put [STAThread] on the Main method of my >console app (gave an error about being unable to switch security contexts >after starting). Never quite understood why, but it was fine until I >started trying to use multiple threads in my app; I'm now getting an error >on my WaitAll() call, saying I can't do this in an [STAThread] application. > >How do I solve this conflict? I have to have multiple threads to make >working with Virtual Server practical. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com