473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multithreading and ActiveX

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 theApplicationF orm As New Form1

<MTAThread()> Public Sub main()
Application.Run (theApplication Form)
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!!

Mar 23 '06 #1
5 5690
"Yeti" <Ye**@discussio ns.microsoft.co m> 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 theApplicationF orm As New Form1

<MTAThread()> Public Sub main()
Application.Run (theApplication Form)
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.

Why do you need MTAThread? You can create threads without this attribute.
Armin

Mar 23 '06 #2
"Armin Zingler" <az*******@free net.de> schrieb
"Yeti" <Ye**@discussio ns.microsoft.co m> 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 theApplicationF orm As New Form1

<MTAThread()> Public Sub main()
Application.Run (theApplication Form)
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

Mar 23 '06 #3
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

"Armin Zingler" wrote:
"Armin Zingler" <az*******@free net.de> schrieb
"Yeti" <Ye**@discussio ns.microsoft.co m> 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 theApplicationF orm As New Form1

<MTAThread()> Public Sub main()
Application.Run (theApplication Form)
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

Mar 23 '06 #4
"Yeti" <Ye**@discussio ns.microsoft.co m> 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

Mar 23 '06 #5
Sounds good...I'm looking into it..thanks

"Armin Zingler" wrote:
"Yeti" <Ye**@discussio ns.microsoft.co m> 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

Mar 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
9691
by: Mark Sisson | last post by:
Hey all. I've got a legacy COM dll that I'd like to use in my multithreaded C# app. Problem though is when I create several instances of the interop object and start them on their own threads they always seem to run synchronously. I've boiled down the code to a simple "lab" experiment below. In this console app you'll see that instance...
3
3132
by: Ed | last post by:
Here's my situation, I am moving some of my apps over from native C++ (primarily Win32 and MFC). One of these apps uses some COM objects in worker threads running in the background where it doesn't bother the user. I'm keeping the native code that interfaces with the COM objects in a DLL since I know it works with no problem (I've used...
16
8480
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
20
3953
by: Cybertof | last post by:
Hello, Is there a good way to call a big time-consumming function from an ActiveX DLL (interoped) through a thread without blocking the main UI ? Here are the details : I have a class CInteropCall encapsulating a call to a visual basic ActiveX DLL function named FillAlloc_ArrayStruct_Double(), which is allocating a big struct array an...
5
2125
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up when I got two threads going at the same time. What I have is two text boxes (textBox1 and textBox2) and four buttons(cmdStartThread1,...
2
2303
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and I just wanted to ask if I am missing anything based on the following scenario. My test app pulls data from a large external data source which...
5
2479
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use multithreading online using C# .
4
2662
by: boo73uk | last post by:
Hi All, I'm going to rewrite a VB6 app to VB.net and I need some pointers. Basically this app spawns simultaneous,multiple, independant ActiveX.exe 'workers' which query a SQL Server database and BCP a load of data out. Now, what is the best way to approach this in .Net? Can .Net give me a better way of utilising the resources of the server?...
7
16288
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or Exceptional C++, for example). Platform-specific (e.g.: Win32, POSIX) is OK, as long as it's good :) Thank you, Ray
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.