List Info

Thread: BackgroundWorker




BackgroundWorker
user name
2006-07-19 07:47:13
I have a program that uses the backgroundworker and also
contains some
ActiveX components. I am getting an error when trying to
initialize the
ActiveX component in the backgroundworker's thread because
it is MTA. Is
there a way I can change the backgroundworker's thread mode
to STA?

Warm Regards

Steven Amani

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

BackgroundWorker
user name
2006-07-19 13:04:11
Nope.  The BackgroundWorker gets threads from the .NET
ThreadPool which
are MTA threads.  You'll have to create the thread yourself
and control
its apartment state manually.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net
/psteele



-----Original Message-----
From: Discussion of writing applications and components
using Visual
Basic .NET [mailto:VBDOTNETDISCUSS.DEVELOP.COM] On
Behalf Of Steven
Amani
Sent: Wednesday, July 19, 2006 3:47 AM
To: VBDOTNETDISCUSS.DEVELOP.COM
Subject: [VBDOTNET] BackgroundWorker


I have a program that uses the backgroundworker and also
contains some
ActiveX components. I am getting an error when trying to
initialize the
ActiveX component in the backgroundworker's thread because
it is MTA. Is
there a way I can change the backgroundworker's thread mode
to STA?

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

BackgroundWorker
user name
2006-07-19 13:35:13
Hi Steven,

I dont think it is possible.

An app can have many MTA's but only one STA which is
already taken by
your app; the main form is running in it.

// Ryan

On 7/19/06, Steven Amani <steven.amanichristiansteven.com> wrote:
> I have a program that uses the backgroundworker and
also contains some
> ActiveX components. I am getting an error when trying
to initialize the
> ActiveX component in the backgroundworker's thread
because it is MTA. Is
> there a way I can change the backgroundworker's thread
mode to STA?
>
> Warm Regards
>
> Steven Amani
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

BackgroundWorker
user name
2006-07-19 14:05:33
I see, so basically if I have any ActiveX components that do
not support
MTA then I need to have them run on the main thread?

-----Original Message-----
From: Ryan Heath [mailto:ryan.q.heathGMAIL.COM] 
Sent: 19 July 2006 14:35
To: VBDOTNETDISCUSS.DEVELOP.COM
Subject: Re: BackgroundWorker

Hi Steven,

I dont think it is possible.

An app can have many MTA's but only one STA which is
already taken by
your app; the main form is running in it.

// Ryan

On 7/19/06, Steven Amani <steven.amanichristiansteven.com> wrote:
> I have a program that uses the backgroundworker and
also contains some

> ActiveX components. I am getting an error when trying
to initialize 
> the ActiveX component in the backgroundworker's thread
because it is 
> MTA. Is there a way I can change the
backgroundworker's thread mode to
STA?
>
> Warm Regards
>
> Steven Amani
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at 
> http://discuss.develop.com

>

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

BackgroundWorker
user name
2006-07-20 08:01:46
> An app can have many MTA's but only one STA
I'll take that back.

Its quite possible to have more than one STA per process.
(Actively
COM programming has been awhile for me... )

Is your object created on/attached to on winform? In that
case you
might want to use Control.Invoke when accessing the object
from the
backgroundworkerthread.

// Ryan

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )