Does VB6.0 support Multi-Thread Programming?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Does VB6.0 support Multi-Thread Programming?

  1. #1
    Join Date
    May 2002
    Posts
    29

    Question 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

  2. #2
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329
    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

  3. #3
    Join Date
    May 2002
    Posts
    29

    Thank you. But...

    Yes,thank you.
    But your sample code in that web site can't be downloaded.

    Originally posted by TimCottee
    Have a look at this http://www.carobit.com/ShowThread/A%...%20Carafa.html

  4. #4
    Join Date
    Apr 2002
    Location
    Los Angeles, Ca
    Posts
    238
    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

  5. #5
    Join Date
    Apr 2002
    Location
    WV
    Posts
    27
    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

  6. #6
    Join Date
    Apr 2002
    Location
    WV
    Posts
    27
    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

  7. #7
    Join Date
    Aug 2004
    Posts
    3
    In vb6.0 Mutl-Threading is not possible

  8. #8
    Join Date
    Mar 2005
    Posts
    226

    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

  9. #9
    Join Date
    Jan 2006
    Location
    the second crappiest place on earth
    Posts
    88

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center