This is a discussion on Main method within the C# Programming forums, part of the Software Development category; Hui guys please let me know Which attribute you generally find on top of main method.....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| STAThread is all about the thread modeling of Windows. STAThread stands for Single Threaded Apartment model. Alternative to STAThread is MTAThread, which stands for Multi Threaded Apartmet model and is default to the CLR execution. That is, if you don't specify any thead model (by coding [STAThread]), the default behaviour is to execute the function under Multi Threaded Apartment. Obviously there is added advantage of executing MTA Thread over STA Thread. 1. what is the relevance of STAThread? Comment: Thread is executing in a single threaded aparment. 2. why is it that we see a huge memory build-up when we use STAThread? Comment: All of your execution path is under single thread and memory reclarim only occurs when your thread stops/pause from execution. 3. when do we have to use STAThread? Comment: It's your design philoshophy. Rule of thumbs is to seperate thread while you're executing a long running task which takes up lot of resources such as memory, TCP/IP or database connection, screen updates etc. That is, start a new thread (usually a MTA Thread) to execute such operation apart from the single thread. 4. what are the performance issues that we might see if we remove STAThread? Comment: Your code will run under MTA Thread, so will be multithreaded. MTA Thread may better utilizes resources and can reclaim memory gradually as it executes. So finally, I think you should run your long running code in a new MTA thread. The following URL may also help you in understanding the Thread model in Windows more clearly: http://blogs.msdn.com/larryosterman/archive/2004/04/28/122240.aspx Hope this may help. thnx.... ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can main method be declared final? | leoraja8 | Java Programming | 1 | 08-28-2007 01:24 AM |
| Main Diffrence Between Perl with Php? | senraj | PHP Programming | 2 | 08-11-2007 08:24 AM |
| What are the main attributes if test automation? | devarajan.v | Software Testing | 2 | 07-27-2007 07:30 AM |
| How to write a Java Application without a main method? | mobilegeek | Java Programming | 1 | 07-24-2007 06:49 AM |
| What are the main phases of QTP? | itbarota | Testing Tools | 2 | 07-24-2007 04:04 AM |