473,218 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

Can BackgroundWorker be Single Threaded Apartment?

I have introduced a component to my solution that is throwing an exception
about needing to be run in single threaded apartment mode. This component is
created in an async call by a BackgroundWorker object, which seems to be on a
MTA thread. Is there a way for me to get the BackgroundWorker thread to run
in STA mode, or do I have to remove the BackgroundWorker and hand spin my own
async call?
Jul 21 '08 #1
2 11796

"Harry Keck" <Ha*******@discussions.microsoft.comwrote in message
news:F0**********************************@microsof t.com...
I have introduced a component to my solution that is throwing an exception
about needing to be run in single threaded apartment mode. This component
is
created in an async call by a BackgroundWorker object, which seems to be
on a
MTA thread. Is there a way for me to get the BackgroundWorker thread to
run
in STA mode, or do I have to remove the BackgroundWorker and hand spin my
own
async call?
Which VB (classic or dotNet) are you using?
Jul 21 '08 #2
On Mon, 21 Jul 2008 06:36:01 -0700, Harry Keck
<Ha*******@discussions.microsoft.comwrote:
I have introduced a component to my solution that is throwing an
exception
about needing to be run in single threaded apartment mode. This
component is
created in an async call by a BackgroundWorker object, which seems to be
on a
MTA thread. Is there a way for me to get the BackgroundWorker thread to
run
in STA mode, or do I have to remove the BackgroundWorker and hand spin
my own
async call?
BackgroundWorker will typically use the thread pool, and AFAIK those are
always MTA threads. Even if they're not, forcing the current
BackgroundWorker thread to be STA could cause other things to break,
because the threads are shared.

In other words, I think that not using BackgroundWorker is the correct
approach. If you have to have an STA thread, you should create your own
thread for the purpose so that you can control its apartment model
explicitly.

Pete

Jul 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob | last post by:
Hi. I'm having difficulty calling a 3rd party COM object that must be called in the apartment (single) threaded model. As far as I know, there are 3 ways todo this: 1 - use "aspcompat=true"...
6
by: ben | last post by:
I am needing a web service to be single threaded. Is this possible? Any ideas would be helpful
8
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item...
11
by: Jamie Bissett | last post by:
I have an application that creates a pretty intensive TreeView at startup time. I had the program running on a single thread sucessfully, but the startup time was a bit excessive. When the...
5
by: Rob R. Ainscough | last post by:
I'm using a BackgroundWorker to perform a file download from an ftp site. Per good code design practices where I separate my UI code from my core logic code (in this case my Download file method in...
6
by: Dustin Davis | last post by:
I've build an application that monitors a folder. When a new file is created in that folder it kicks off a process. On such process is to load a form. When I get to the statement to create and...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
0
by: mike1reynolds | last post by:
While my project is in an STA state, when I added a class with no form it is executing in an MTA state. I can't find any reference to MTA or STA anywhere in the entire solution. How do I set a class...
2
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have introduced a component to my solution that is throwing an exception about needing to be run in single threaded apartment mode. This component is created in an async call by...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.