-
May 20th, 2002, 06:37 AM
#1
Does VB6.0 support Multi-Thread Programming?
Hi,
Do you know if VB6.0 supports Multi-Thread Programming?
I wrote a sample according to MSDN, but I got an Exception while I run its .exe file.
My code is as below:
...
Dim lpThreadId As Long
lThreadHandle1 = CreateThread(ByVal 0, ByVal 0, AddressOf test_function, 0,0, lpThreadId)
...
If VB6 supports CreateThread() API,would you like give me a sample vb project?
Thank you.
xadave@sina.com
-
May 20th, 2002, 07:00 AM
#2
TimCottee
I know a little about a lot of things and a lot about very little.
Brainbench MVP For Visual Basic
http://www.brainbench.com
MCP, MCSD, MCDBA, CPIM
-
May 20th, 2002, 07:06 AM
#3
Thank you. But...
Yes,thank you.
But your sample code in that web site can't be downloaded.
-
May 21st, 2002, 01:23 PM
#4
WangDave .... I downloaded it today... 5/21/02 ... at the bottom of the first paragraph there is a download link for a WinZip file
I also copied the explanation posted by the author and put both into a folder.
By the way .. my opinion ... GREAT THREAD . Question is very good and properly detailed .. and the answer is equally helpful.
Michael
-
May 21st, 2002, 08:11 PM
#5
VB 6 does not support multithreading. VB 6 apartment threaded objects and programs are limited to execution in an STA (Single Threaded Apartment). This means that your exe or object can spin up as many threads as it wants, but only one thread in the apartment can execute at a time (no concurrent execution). Even if you use an out of process object (COM object in an exe) you will only get two threads (the one for your calling program and one for the COM exe) and each of them will be in an STA. VB.NET, however, supports an additional threading model, the free threading model, which forces an object to execute in an MTA (Multi Threaded Apartment), this threading model allows multiple concurrent threads of execution.
Hope this helps.
Spectre
-
May 21st, 2002, 08:14 PM
#6
I'd like to add that the reason for this threading behavior in VB 6 is to allow VB 6 objects to be thread safe (safe to call from true multithreaded applications written in other languages). So, although you can spin up additional threads from your VB6 application, you can't get concurrnet execution (true multithreading).
Spectre
-
August 6th, 2004, 06:59 AM
#7
In vb6.0 Mutl-Threading is not possible
-
June 10th, 2006, 11:11 AM
#8
Re: Does VB6.0 support Multi-Thread Programming?
Multi-Threading is possible in VB 6. All you need to do is create an ActiveX.exe but be careful on how you resond to events by making sure you don't block yourself or you ActiveX.exe
-
June 11th, 2006, 12:34 AM
#9
Re: Does VB6.0 support Multi-Thread Programming?
We have production multi-threaded code VB6 code that's been in the field for years, using the CreateThread, et al, method... and yes, you have to be careful with blocking, etc, just like you would in any language.
wangdave, one thing we've found, however, is that you can't compile the code as Native, you've got to use P-Code. I'm not completely sure why, but it might be causing your exception.
Hope that helps...
Joe Plocki
Sometimes the straightest path is through the mud.
O|||||O
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|