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?
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?