Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically.
However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA
by default. I can change this to MTA if I want to. But, what is the use of
this? Is it bad? Good? Can anyone give me a practicle example of when you
should use STA and when MTA?
Cheers,
Razzie 7 9829
It is generally a bad idea as there are a nunber of UI things that use COM as a backbone. This will expect (due to the thread sensitivity of UI code) to have the code accessed from an STA thread. If you have any activeX controls on your form (you may have them unknowingly by using a 3rd party control) or you want to use OLE drap and drop (which won't be initialized if you use MTAThread) there will be issues.
Regards
Richard Blewett - DeveloopMentor http://staff.develop.com/richardb/weblog
Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically.
However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA
by default. I can change this to MTA if I want to. But, what is the use of
this? Is it bad? Good? Can anyone give me a practicle example of when you
should use STA and when MTA?
Cheers,
Razzie
Hi,
AFAIK win apps should be declared as STA this is required for some win
controls. so I would not change that.
take a look at this article : http://blogs.msdn.com/cbrumme/archiv.../02/66219.aspx
it explain it a little bit more.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Razzie" <ra****@quicknet.nl> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's -
theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a
STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
Razzie,
Aside from what previous posters have mentioned, is there a reason that
you want to do this? What benefit are you seeking from doing this?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Razzie" <ra****@quicknet.nl> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
Hi Razzie,
If you change the UI thread to be MTA you'll change it back very soon :)
You'll get an exception saying that STA is required by WindowsForms. That is
because WindowsForms uses COM. Chances not to get that exception are not
big.
--
Stoitcho Goutsev (100) [C# MVP]
"Razzie" <ra****@quicknet.nl> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
I scanned that blog - it's why I asked this question actually :) It's good
theory, but it does not explain the practical use of it AFAICT.
Thanks.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:O2****************@TK2MSFTNGP12.phx.gbl... Hi,
AFAIK win apps should be declared as STA this is required for some win controls. so I would not change that.
take a look at this article : http://blogs.msdn.com/cbrumme/archiv.../02/66219.aspx
it explain it a little bit more.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Razzie" <ra****@quicknet.nl> wrote in message news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
Hello Nicholas,
It is pure curiousity and from an eductational point of view, actually. I've
made multi-threaded applications, but never knew about the STA and MTA. So I
was wondering - when do you use STA, when MTA, what are the differences in
terms of performance.
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl... Razzie,
Aside from what previous posters have mentioned, is there a reason that you want to do this? What benefit are you seeking from doing this?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Razzie" <ra****@quicknet.nl> wrote in message news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
Hi Razzie:
You can make your application multi-threaded without changing the
apartment state.
In general, the only time you want to explicitly set the apartment
state is if you are doing COM interop with STA components. You want
your thread apartment type to match the threading model of any COM
objects the thread uses to minimize performance hits. As other posters
pointed out, there are additional reasons for setting the STA state
for Main.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 26 Oct 2004 16:06:43 +0200, "Razzie" <ra****@quicknet.nl>
wrote: Hello Nicholas,
It is pure curiousity and from an eductational point of view, actually. I've made multi-threaded applications, but never knew about the STA and MTA. So I was wondering - when do you use STA, when MTA, what are the differences in terms of performance.
Thanks,
Razzie
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... Razzie,
Aside from what previous posters have mentioned, is there a reason that you want to do this? What benefit are you seeking from doing this?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Razzie" <ra****@quicknet.nl> wrote in message news:uh**************@TK2MSFTNGP15.phx.gbl... Hey all,
I somewhat know of the differences between STA's and MTA's - theoratically. However, when it comes to practical use of this, I don't.
When I create a simple WinForms application, the main process runs in a STA by default. I can change this to MTA if I want to. But, what is the use of this? Is it bad? Good? Can anyone give me a practicle example of when you should use STA and when MTA?
Cheers,
Razzie
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alvin Bruney |
last post by:
Excerpt as follows:
We have developed a .Net application that makes use of WebServices to access
a PeopleSoft (Oracle) database using the PeopleSoft 8.4 COM API. When the
application is...
|
by: Jazper Manto |
last post by:
hi
i read thousands of millions of articles about STA and MTA :-). everything
very theoretical and i don't get it...
could anybody explain me the and on a nice, small
and simple example where...
|
by: Venkat |
last post by:
Hi,
We have a dozens of VB6 components, developed some 5 years before, we
have now few .Net components which references these files. Ideally we are
using Biztalk server and referencing these VB6...
|
by: Alper AKCAYOZ |
last post by:
Hello,
There are MTA and STA ApartmentStates at Thread documentation in MSDN. I
could not understand the explanations in MSDN. Can you kindly explain the
differences and advantages of using MTA or...
|
by: Adriano Coser |
last post by:
Hello.
I'm moving an application VC 2003 to VC 2005 Beta2. I need to set STA
ApartmentState model so the drag & drop registration can work.
I used to do...
|
by: Raul |
last post by:
So, here it is:
I have a 3'rd party API written in C that is Single Threaded(state is saved
between different commands, locks and so on - so i'v heared).
The only way i was able to use it is...
|
by: Peter Row |
last post by:
Hi,
I think I am having some threading issues in a project I am porting from VB6
webclass to VB.NET.
Therefore I would like to temporarily set the threading mode to STA to get
around it until I...
|
by: mike1reynolds |
last post by:
In a background worker threads are MTA, while UI threads must be STA. Attempting to instantiate a form class in a background worker throws an exception, so invocation of a delegate is required.
My...
|
by: mitrrahul |
last post by:
HI Friends,
I am facing a problem while joining a STA thread to MTA thread. Actually the requirement was some thing like describe below.
1. I have a exe which is using some dialog boxes.
2....
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
| |