.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

what is accomplished by decorating a C-Sharp Main Subroutine with MTAThread vs. STAThread.

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

Can you please tell what is accomplished by decorating a C-Sharp Main Subroutine with MTAThread vs. STAThread.

I have read couple C-Sharp Multithreading books, but I did not find any explanation of applicability of STAThread or MTAThread in C sharp code.

Why are such attributes needed in a C-sharp code in the first place ?

I had a Console Application where its Main was decorated with STAThread by default. Everything worked without problem. Then I added a WCF service, which services a separate GUI Client application. When I use the GUI, my Console application gives a ContextSwitchDeadlock error. The only way I can get rid of the error is by marking the MAIN MTAThread. But I do not why the error goes away. 

Also, My Console Application does use a COM Based service, but I do not know if that has a bearing on this problem or not.

Help appreciated. 

Thank you

View Complete Post

More Related Resource Links

stathread, mtathread

What is STAThread, MTAThread... I remember .NET CF didnot support MTAThread... why main() is decorated with them...
- Rajesh K http://thoughtsontechies.blogspot.com/

Trim function in C Sharp

How do i use "trim" function in C Sharp? I have a string and i want to strip off spaces from the end of the string. Any idea how do i do it??


Sharp New Language: C# Offers the Power of C++ and Simplicity of Visual Basic


Many developers wish there was a language that was easy to write, read, and maintain like Visual Basic, but that still provided the power and flexibility of C++. For those developers, the new C# language is here. Microsoft has built C# with type-safety, garbage collection, simplified type declarations, versioning and scalability support, and lots of other features that make developing solutions faster and easier, especially for COM+ and Web Services. This article gives you a first look at C#, a language you are going to be hearing lots more about in the very near future.

Joshua Trupin

MSDN Magazine September 2000

Reg: Turn on more accessible mode & Skip to main content link message on Infopath2007 browser form



I have a infopath 2007 browser enabled form with c# code behind . The Infopath form is embeded\hosted in to a custom layouts page (.aspx) on MOSS 2007. The issue is when users use keyboard to fill the form, they often use <TAB> & <Enter> keys. So when they are using the tabbing at one location in the form, I have a "Contact selector" field, I enter a name & then hit <TAB> key the focus now comes to "name cheker" I then hit <Enter> key, I hit <TAB> again, the focus now comes to a button named "Accept", I hit <Enter> key & a filed below is populated with the values from user profile service. Now when I hit <TAB> I expect the focus should now come to that automatically populated field below the "Contact selctor". Because Infopath assings the tab order by default form top to bottom & left to right and I havent changed that default tab order.   

But, the focus moves to top of the webpage with a clickable link to "Turn on more accessible mode" I hit tab one more time & the link on top changes to "Skip to main content". This bheaviour does not seem to be happning in other form controls when they hit <Tab>, <Enter>. There are couple of areas on the infopath form where I have such a controls (layed ou

close pop up and refresh main page after popup close

I am working on a application in which When user clicks on a button  he should be redirected to facebook login page and after successfull login he shud be reirected back to my page. It all is working fine but now I have to do like thiswhen user click on the Button the the facebookbacklogin page shud be opened in popUp and when login is done successfully the popup window shud be closed and the main page shud be refreshed. anf If user is already login the popup window shud not be opened.How can i do this..How can I KNow that a popup window is opened and how can I close that??How to refresh when popup window is closed.I ahve to do like on this site..http://blippy.com/

internal hyperlink is not showing in main web site hyperlink list

Hi, I am using sharepoint designer 2007. I move data from 32 bit to 64 bit architecture. some of the hyperlinkslinks are not showing in my website hyperlink list hence site is not working correctly. what should I do? How can I show internal hyperlink?  

Usercontrol, in master page, calling a method on the main page?

I have user control called 'Header.asxc' that is registered in my master page. That user control has an image link. The clicking of this link needs to cause a dropdown on the main page to repopulate. I am comforable with delegatges, with populating the dropdown etc... My problem is I cant find the usercontrol from the page, in order to set the function event. I got this work previously when the user control was registered on the page in question but this case with the master page  has me confused. Here is a summary of the set up. 1. I put this in the Header.ascx usercontrol that is registered by the Master page. public Delegate locReloadCompanyDropdown;2. Further down in that page in the relevent _Click event, I put this. locReloadCompanyDropdown.DynamicInvoke();3. Back in the main page I declared these.. public delegate void reloadCompanies(); private event reloadCompanies doReloadCompanies;4. Finally I try to set the delegate doReloadCompanies += new reloadCompanies(PopulateCompanyDropdown); //Page.Header.locReloadCompanyDropdown = doReloadCompanies; //Header.locReloadCompanyDropdown = doReloadCompanies;You can see a couple of attempts I have made remarked out in the code above. Neither work. What am I missing here? Thanks all.  

How to pass parameters from Application Main method to modules.

Hi , We created Prism WPF application.we have to pass some parameters(some information) to modules(they are instantiated by Bootstrapper) from Main method of App.xaml  Thanks in Advance.

Formula on Main Report Using a Field from Subreport

Hi, I try to use a value coming from a cell which contain a subreport. I need to create a formula using this value. So I tried : =Code.CalcPct(CountDistinct(Fields!s_contactsvisited.Value), Globals!CALL_SubReport) But I've an error: [rsRuntimeErrorInExpression] The Value expression for the textbox textbox9 contains an error: Specified argument was out of the range of valid values. Thanks for you help,      

adding quicklinks/tree navigation to main search page (search 2010 express)

Hi Just installed Search Server 2010 Express (full version). On the previous version you could add the top link bar to the search page to easily allow you to browse to other sections i.e contacts. With 2010 I cannot seem to add any kind of navigation away from this main page (default.aspx). Using Designer it will not allow me to edit the top bar, quick launch, tree view and top link bar have been enabled with links however they do not show up on the main search page. can someone help ?

returning from frame to main page

Hi,   I have a main page with some buttons on it.If the user clicks on a button, a frame is created in the center and a order (web)form is shown.At the end of the form, when the order is placed, I want to close the frame somehow. What would be the best way to do this? If I do a redirect on the page that is in the frame, it just opens the main page in the frame, which isn't what I'm looking for of course. rg,Eric 

How to pass value from main report to sub report

I need pass sub report calculated  value in main report  using crystal report please help me

Default Application "does not contain a static 'Main' method suitable for an entry point"

Hi, When I create a brand new WPF application project in Visual Studio 2010 and immediately try to run it, I get the error WpfApplication1.exe does not contain a static 'Main' method suitable for an entry point. App.xaml's build action is set to ApplicationDefinition. I think it's not generating App.g.cs. Does anyone know what's wrong?

sharepoint branding ms-main question

I have written my own custom CSS how do i control image header.jpg depending on the screen resolution . It gets skewed for different resolutions .. Thanks /* display our custom header background */ .ms-main { background: white url('Header.jpg') no-repeat left top; } /* make the top bar and the bar behind nav transparent */ .ms-globalbreadcrumb, .ms-globalTitleArea, .ms-bannerContainer { background-image: none !important; background-color: transparent !important; } /* increas the hiehgt of the header area */ .ms-globalTitleArea { height: 100px; } /* hide the site title and site icon */ td.ms-titleimagearea img, .ms-sitetitle h1.ms-sitetitle { display: none; } /* hide the bottom border on the top bar */ td.ms-globalbreadcrumb { border:0px transparent none !important; } /* advanced search color */ .ms-globalTitleArea .ms-sblink a:link, .ms-globalTitleArea .ms-sblink a:visited, .ms-globalTitleArea a:hover { color: white; } /* fix for firefox top bar */ td.ms-globallinks { white-space:nowrap; } http://picasaweb.google.com/103330992872334209006/UntitledAlbum#5514926743118804882 high resolution pic I can see the whole picture(1280 X 800) low resolution pic I can just part of the picture ( 600 X 800) if you can help with this that would be great

can the void main function be called all the time, when activated as a feature.

Hi, I have a console application using C#, in which i have a custom code under the static void main. I would like to know, if the console application is made to a feature and activated, will the static void main function be called all the time, without waiting for any events to be trigerred. Thank you
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend