473,491 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

i want to run my app in STA, not MTA

Hi:

How would I go about making sure my C# 2.0 app runs under STA, not MTA? Do
I add something in the Main method?

Thanks
Jun 1 '06 #1
2 1477
Tarren wrote:
Hi:

How would I go about making sure my C# 2.0 app runs under STA, not MTA? Do
I add something in the Main method?

Thanks


You just need to use the STAThread attribute.

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

If you're using a separate thread, the System.Threading.Thread class has
a SetApartmentState method.

Dan Manges
Jun 1 '06 #2
That is so easy it is almost annoying. :)

Thanks.
"Dan Manges" <da***********@gmail.com> wrote in message
news:GF******************@tornado.ohiordc.rr.com.. .
Tarren wrote:
Hi:

How would I go about making sure my C# 2.0 app runs under STA, not MTA?
Do I add something in the Main method?

Thanks


You just need to use the STAThread attribute.

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

If you're using a separate thread, the System.Threading.Thread class has a
SetApartmentState method.

Dan Manges

Jun 1 '06 #3

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

Similar topics

0
1504
by: reynArd | last post by:
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want....
0
1336
by: reynArd | last post by:
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want....
7
1776
by: Anne M | last post by:
I have a report based on query..which is a team list with names and their role on team ie coach, assistant and player. Report is almost what I want and my knowledge is limited so I need some...
0
1248
by: reynArd | last post by:
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want....
182
7351
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.