IT Community - Software Programming, Web Development and Technical Support

Main method

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.....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-16-2007, 07:49 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Post Main method

Hui guys please let me know Which attribute you generally find on top of main method..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-16-2007, 10:18 PM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Main method

hey,

[ STAThread ] attribute will be find on top of the main method.
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-16-2007, 11:06 PM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Default About STAThread

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....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 11:56 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0