I've had this issue before, where the loading of an STA threaded COM component causes the whole process to pause in a wait state indefinitely.
The way I solved this was to create a new Thread, make it STA threaded then point it to a method which then loads the COM component. This solved the problem for me. Otherwise another method of solving this is to Invoke onto the main UI thread the function which will load the COM control. Regards, Chris -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of James Bishop Sent: Wednesday, 13 April 2005 9:21 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] UI thread problems One thing that could cause your main thread to block is if the message queue stuff uses COM, and it uses ThreadingModel of Apartment or Both, and you create your message queue class in the main form, then it will be loaded into the main form STA. Then if you use that same class from your other threads, the calls to that class will be marshalled into the sta thread, possibly blocking the UI thread? Theres a lot of ifs and buts in that though... A possible solution is to have your main method start on an MTA thread, but then fire up an STA thread which hosts your main form. Anyway I think you definitely have some sort of COM threading problem, hopefully someone else here can shed some more light on it... If you google for 'STAThread MTAThread' you can find some good info. Here are a couple I found helpful: http://www.codeguru.com/Cpp/COM-Tech/activex/apts/article.php/c5533/ http://udidahan.weblogs.us/archives/015716.html > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED] On Behalf Of Ross Diesel > Sent: 13 April 2005 08:00 > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] UI thread problems > > Have followed your suggestion and the main form now at least remains > responsive, however a consequential issue is... > > exceptionSystem.Threading.ThreadStateException: Could not instantiate > ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' because the current > thread is not in a single-threaded apartment. > at System.Windows.Forms.Control.MarshaledInvoke(Control caller, > Delegate > method, Object[] args, Boolean synchronous) > at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) > at > AbsoluteSystems.Interact.RunTime.ChannelIO.PresentationService.CioPresen ta > ti > onManager.SetupSessionViews(String sessionType, String sessionId) in > S:\RunTime\ChannelIO\Src\CioPresentationService\CioPresentationManager.c s: > li > ne 1074 > > I believe that the MS web browser control I am using has a thread affinity > for the main STA thread, so am not sure how to address this new issue i.e. > how do I find the correct thread to create the browser control on. > > >From my understanding of COM, a process can support multiple STAs but > only > one MTA, so it does not (or does it???) neccessarily follow that STA based > components would load themselves into the main STA thread in the initial > AppDomain. > > Prior to this attempt to integrate the presentation service into our > product, I have been using message queues to receive events on the > listener > thread, session threads were subsequently spawned which raised their own > dialogs, presumably on the session thread and there were no UI issues, > so... > I would think its safe to assume that STA based COM components are not > neccessarily loaded into the main STA thread. Can anyone provide a > reference > which addresses this issue - it might provide further insight into the > above > problem. > > regards =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by NetIQ MailMarshal ##################################################################################### =================================== This list is hosted by DevelopMentorŪ http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com