|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multithreading and ActiveXHey everyone, I am modifying code upgraded from VB 6 to 2005. I need to run
the 2005 code in the MTA mode so I set a sub main procedure in my module which runs first when the program starts: Public theApplicationForm As New Form1 <MTAThread()> Public Sub main() Application.Run(theApplicationForm) End Sub However, when this launches the Form1, I receive the following runtime error: {"ActiveX control '6262d3a0-531b-11cf-91f6-c2863c385e30' cannot be instantiated because the current thread is not in a single-threaded apartment."} I don't know how to proceed from here. I realize that the ActiveX component is something old VB6 code still being used..I believe it is an MSFlexGrid. How do I run my program as multithreaded successfully? MANY THANKS!!
Show quote
Hide quote
"Yeti" <Y***@discussions.microsoft.com> schrieb If you use the ActiveX control, you must use the STAThread (or no) > Hey everyone, I am modifying code upgraded from VB 6 to 2005. I need > to run the 2005 code in the MTA mode so I set a sub main procedure > in my module which runs first when the program starts: > > Public theApplicationForm As New Form1 > > <MTAThread()> Public Sub main() > Application.Run(theApplicationForm) > End Sub > > However, when this launches the Form1, I receive the following > runtime error: {"ActiveX control > '6262d3a0-531b-11cf-91f6-c2863c385e30' cannot be instantiated > because the current thread is not in a single-threaded apartment."} > > I don't know how to proceed from here. I realize that the ActiveX > component is something old VB6 code still being used..I believe it > is an MSFlexGrid. How do I run my program as multithreaded > successfully? MANY THANKS!! attribute. Why do you need MTAThread? You can create threads without this attribute. Armin
Show quote
Hide quote
"Armin Zingler" <az.nospam@freenet.de> schrieb Skip the "(or no)" words. Default is MTAThread for the main procedure of the> "Yeti" <Y***@discussions.microsoft.com> schrieb > > Hey everyone, I am modifying code upgraded from VB 6 to 2005. I > > need to run the 2005 code in the MTA mode so I set a sub main > > procedure in my module which runs first when the program starts: > > > > Public theApplicationForm As New Form1 > > > > <MTAThread()> Public Sub main() > > Application.Run(theApplicationForm) > > End Sub > > > > However, when this launches the Form1, I receive the following > > runtime error: {"ActiveX control > > '6262d3a0-531b-11cf-91f6-c2863c385e30' cannot be instantiated > > because the current thread is not in a single-threaded > > apartment."} > > > > I don't know how to proceed from here. I realize that the ActiveX > > component is something old VB6 code still being used..I believe it > > is an MSFlexGrid. How do I run my program as multithreaded > > successfully? MANY THANKS!! > > > If you use the ActiveX control, you must use the STAThread (or no) > attribute. startup thread. > Why do you need MTAThread? You can create threads without this Armin> attribute. Thanks for getting back to me Armin. I need to use the MTAThread so that I
can subscribe to an OPC server. Any workarounds or should I just delete all the ActiveX's?- Owen Show quoteHide quote "Armin Zingler" wrote: > "Armin Zingler" <az.nospam@freenet.de> schrieb > > "Yeti" <Y***@discussions.microsoft.com> schrieb > > > Hey everyone, I am modifying code upgraded from VB 6 to 2005. I > > > need to run the 2005 code in the MTA mode so I set a sub main > > > procedure in my module which runs first when the program starts: > > > > > > Public theApplicationForm As New Form1 > > > > > > <MTAThread()> Public Sub main() > > > Application.Run(theApplicationForm) > > > End Sub > > > > > > However, when this launches the Form1, I receive the following > > > runtime error: {"ActiveX control > > > '6262d3a0-531b-11cf-91f6-c2863c385e30' cannot be instantiated > > > because the current thread is not in a single-threaded > > > apartment."} > > > > > > I don't know how to proceed from here. I realize that the ActiveX > > > component is something old VB6 code still being used..I believe it > > > is an MSFlexGrid. How do I run my program as multithreaded > > > successfully? MANY THANKS!! > > > > > > If you use the ActiveX control, you must use the STAThread (or no) > > attribute. > > Skip the "(or no)" words. Default is MTAThread for the main procedure of the > startup thread. > > > Why do you need MTAThread? You can create threads without this > > attribute. > > > > > Armin > > "Yeti" <Y***@discussions.microsoft.com> schrieb Why not start another thread that communicates with the OPC server? If you > Thanks for getting back to me Armin. I need to use the MTAThread so > that I can subscribe to an OPC server. Any workarounds or should I > just delete all the ActiveX's?- Owen do it, be aware of what the docu says: You must set the ApartmentState property of the other thread before you start it. Armin Sounds good...I'm looking into it..thanks
Show quoteHide quote "Armin Zingler" wrote: > "Yeti" <Y***@discussions.microsoft.com> schrieb > > Thanks for getting back to me Armin. I need to use the MTAThread so > > that I can subscribe to an OPC server. Any workarounds or should I > > just delete all the ActiveX's?- Owen > > > Why not start another thread that communicates with the OPC server? If you > do it, be aware of what the docu says: You must set the ApartmentState > property of the other thread before you start it. > > > Armin > >
what is Xtreme Sample Database
Data Source with ReportViewer DataGrid Custom Styles Learning - displaying selection in pictureboxes Null, DBNull, Nothing, VBNullstring how to avoid broken references when give out projects Help needed using sample RS232 class to read from serial port How display Result from sqlCommand select in the Datagridview Small bit of code from VB6 to VB.net - desperate need of help Icon |
|||||||||||||||||||||||