Home All Groups Group Topic Archive Search About
Author
10 Oct 2005 3:11 PM
Dick
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?

Author
10 Oct 2005 3:48 PM
Lloyd Dupont
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...

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
Show quote
"Dick" <Richard.Giles@nospam.nospam> wrote in message
news:D1271A56-0EDF-47C9-8F87-5BA9BDDBE762@microsoft.com...
> 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?
Author
11 Oct 2005 2:03 AM
Peter Huang" [MSFT]
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.
Author
10 Oct 2005 6:15 PM
Michael D. Ober
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.

Show quote
"Dick" <Richard.Giles@nospam.nospam> wrote in message
news:D1271A56-0EDF-47C9-8F87-5BA9BDDBE762@microsoft.com...
> 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?
>
Author
11 Oct 2005 8:14 PM
Ollie Riches
this google thread might help

http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/browse_frm/thread/b2e8c76cd1cdb31b/6f7c82a3b705b2ab?lnk=st&q=ollie+threading+com&rnum=5&hl=en#6f7c82a3b705b2ab

HTH

Ollie Riches
Show quote
"Dick" <Richard.Giles@nospam.nospam> wrote in message
news:D1271A56-0EDF-47C9-8F87-5BA9BDDBE762@microsoft.com...
> 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?

AddThis Social Bookmark Button