Originated from
Generic

Facing problem when STA thread joins MTA thread

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. These dialog boxes are using MSFlexGrid. This component is a Com component. 3.so in order to run it with Vb.Net exe i had to run this dialog box in a STA thread. 4. to achive this i created a new thread and set the Apartment status STA. 5.it was working fine when i run the code. but if click on exe than at the time of join it throws an unhandled exception.if i click on continue button of exception dialog box it runs successfully. how ever i can not ignore this exception. 6. exception contains below text (i know its a bog message but i am stuck here for last couple of days.). ************** Exception Text ************** System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at MSFlexGridLib.IMSFlexGrid.get_Text() at AxMSFlexGridLib.AxMSFlexGrid.get_Text() at System.Windows.Forms.Control.OnHandleDestroyed(EventArgs e) at System.Windows.Forms.AxHost.DetachWindow() at System.Windows.Forms.AxHost.DetachAndForward(Message& m) at System.Windows.Forms.AxHost.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 7. COde snippet is like below. Dim paramtThread As New Threading.ParameterizedThreadStart(AddressOf DelgInvoke) Dim exeThread As New Threading.Thread(paramtThread) exeThread.SetApartmentState(Threading.ApartmentState.STA) exeThread.Start(mbrs)// mbrs is a structure variable. exeThread.Join() Please let me know if any one have any idea. i am totaly clueless here. it would be a great help.


Share Send to a friend Watch Report
 
 

Posted Answers

No answers were posted yet - be the first one to answer!

Sign in to participate

Got an answer for mitrrahul? Would you like to comment on the posted answers, or vote for the one which you think is the best?

Sign up for a free account, or sign in (if you're already a member).

Explore Related Questions

Other people asked questions on similar topics, check out the answers they received:


Q:

How long does an mta night track worker really ...

how long does an mta night track worker really work, is it the whole night?
Submitted by ccmv   2 years ago.
  • viewed 16 times


Q:

What year did MTA announce elevator installation

what year did MTA announce elevator installation
Submitted by BigSexcy   1 month ago.
  • viewed 11 times


Q:

How can i hide the day i joined youtube? i dont ...

how can i hide the day i joined youtube? i dont want people to know i just joined today. Is there anyway i can hide this info from ...
Submitted by winxchinx   5 months ago.
  • viewed 200 times



» More...

Explore Related Posts in Forums

Questions about apartment threading models

Completely grasp meaning and usage of MTA and STA threading models. My questions are : 1 that never make any COM calls - not even CoInitialize. When a thread joins an apartment (by calling by". If the threading model of the object is compatible with the apartment whose thread calls CoCreateInstance...

Joining a STA thread to a MTA thread

HI Friends, I am facing a problem while joining a STA thread to MTA thread. Actually it with Vb.Net exe i had to run this dialog box in a STA thread. 4. to achive this i created a new thread... a STA with MTA. i have tried event mechanism also, but it seems like when this thread dies it gives...

ContextSwitchDeadlock - C# / C Sharp

The error "The most probable cause is that a single-threaded apartment (STA) thread is not pumping messages. The STA thread is either waiting without pumping messages or is performing lengthy operations saying you can't have a SQL Statement that joins a table on a database in another server? You should
» More...
Powered by
Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
ADVERTISEMENT
AOL Autos Q&A is powered by Yedda an AOL Company
Copyright © 2006-2009, Yedda Inc. and respective copyright owners