Threading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My (VB.net) application successfully calls some 3rd party COM-based software.

But I want to change my application so the main code runs on a background
thread leaving the foreground thread free to handle a "progress" form. But
after I do so the call to the 3rd party software fails.

I'm sure this is something to do with threading because it all starts to
work again if I create a "dummy" form, and then add to the dummy form the
code that calls the 3rd party software, and then marshal my calls to the 3rd
party software via the form's BeginInvoke method.

So my questions are (a) is there a better way of configuring the threads so
that the call to the 3rd party software doesn't fail (I've tried setting the
ApartmentState property) and (b) is there a better way to ensure the code
that calls the 3rd party software runs on the main thread, i.e. to achieve
the same as Form.BeginInvoke but not have to create a "dummy" form?
 
well if
[STAThread]
Main()
{
}
doesn't work that's... weird....
if it's the case you will have to use a dummy form, I'm afraid...
 
Sounds like the 3rd party control wants to be on a form. There's nothing
you can do about this other than to create a dummy form that you never
display.

Mike.
 
Hi

Based on my understanding, you create the dummy form on the First thread(UI
thread), and use the Form.BeginInvoke to call the COM object successfully.
I guess that may be concerned about the limitation of the third party COM
Object, it may need to run on the Main Thread(first thread), or it may need
a thread with UI.
So I suggest you contact the third party COM Object development/vendor
directly to query for more information.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top