CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    1

    Multitreading with WINAPI in VB

    Hi,

    I try to make a kind of multitreading app in VB. My first prototype was using VB timer. This kind of timer hang the form when running because they use the form message loop. In this forum and other place, I have see a couple of people using the WINAPI function set to run multithreading application. I want to use this solution for my second prototype but I am still not convince of the VB stability when you begin to play with CreateThread and WINAPI timer.

    Do you have any experience of making BIG application in VB using a multithreading architecture? I hope having 4 thread running in to of the form, some synchronization objects between thread and a refresh of 10 Hz. Does it to much for VB? At this point do it better to go for VC++?

    All comments will be very appreciate.



  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Multitreading with WINAPI in VB

    multithreading in VB is really a big topic to learn, especially if you want to make it run stably. check out Matthew Curland book - Advanced Visual Basic 6, which talk about multithreading in details and make it work stably. And if you can wait until VB.Net, which support multithreading, then just wait and save you a lot of work.

    I used to use CreateThread to do multithreading in VB. somehow, after I read some article from some well-known GURU. using CreateThread alone is a rubbish !!! you must consider the COM way of doing multithreading in VB apartment model, especially in setting up the TLS and so on.

    Thus, the best is to get deep knowledge into multithreading of VB from some expert guide, like the book that I recommend.




    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

  3. #3
    Join Date
    Jun 2001
    Location
    CO
    Posts
    3

    Re: Multitreading with WINAPI in VB

    Yes, defintitely check out Matt's book. It has so many great topics in there, including multithreading. I used Matt's architecture for multithreading with a few mods, and it works.
    I had to multithread data retrieval (through RDS) that can sometimes take 20 min.
    However, his architecture requires Service Pack 4 of the vbruntime (msvbvm60.dll).
    As the book explains, using the CreateThread API is tricky because once you've created a thread, all VB code comes to a stop until the first object is created on that thread. Its a catch 22, bec. how else are you going to create object..if the code to do so won't even run. So set x = createobject("blah") won't work, in that thread. You have to create the object using the Win API's like CoCreateInstance, etc. He declares entry points to these API's through a type-library bec. I guess he encountered some problems with VB Declare statements sometimes not working.
    At any rate, 1) definitely buy the book, I can't say enough about it; 2) I can attest to Matt's architecture for creating threads..it works..I've seen cases where it locks up on me though, and I'm not sure why. I temporarily solved it by managing my attempts to create the thread.


  4. #4
    Join Date
    Jul 2000
    Posts
    110

    Re: Multitreading with WINAPI in VB

    True multithread VB source serial port control:
    http://www.banasoft.com/DownLoad/BNComm.exe

    True multithread VB source multimedia timer control:
    http://www.banasoft.com/DownLoad/BNTimer.exe


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured