Results 1 to 9 of 9

Thread: "Multithreading" in VB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Question "Multithreading" in VB

    I am working on a small app that pings servers to determine if they are "live" on the network. When the PING responds, a treeview is updated with the server being shown as red or green (green being up; red being down).

    Problem is that my app is only able to execute for one server at a time. Fine for a couple of machines. But when I get up to 200-300 servers, this will be an issue.

    I need a way to create an outside object (i.e. ActiveX EXE) that does the dirty work and responds to the host app with the status (Red or Green). This way the main app is only responsible for executing the outside object and maintaining the GUI. The external object gets the hard work...

    Also, in this situation... how do I manage 50+ instances of a single object?

    Does anyone have any sample code that I can look thru for Raising Events and/or managing object arrays or something that would fix my problem?

    Thanks in advance!
    Kevin
    Kevin

  2. #2
    DaoK
    Guest
    You can not Multithreading in vb .

  3. #3
    Originally posted by DaoK
    You can not Multithreading in vb .
    Sort of. For standard EXEs you can only multithread in the IDE which makes it pretty worthless. I believe it was Joacim who said that you could use either an ActiveX EXE or an ActiveX DLL to do much cleaner multithreading. Either way VB isn't good for it; if it is mission critical then use another language, especially Java which is incredibly easy to multithread in.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by DaoK
    You can not Multithreading in vb .
    Actually this is not really true.
    VB use an "Apartement Threading" module.
    Since ksutton is using an ActiveX Exe you have a "free thread" for every instance of this object.
    The problem is that you can't use the WithEvents keyword with object arrays which is what he wants to do.

    I don't have a solution for the problem though, I just wanted to make this point clear (which from reading your post, ksutton, I suspect you know already)

    Best regards

  5. #5
    hellswraith
    Guest
    This is theory,

    Create a Active X EXE. The main class is what you call and get events from. The main class in turn, creates an array of other classes in the EXE. Instead of getting events from them, it could just pole their properties by using the Friend property let, and get statements (maybe a continuous loop on a timer). It could report back progress and what nots to the client through it's event passing an object number, status, etc.

    Just a thought, but the only problem with this is that all objects are still on the same thread of execution. But it will be seperate from the client thread.

    Think that could work? Or do I need to go to sleep now?

  6. #6
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    you can multi-thread in vb, you just have to be tricky about it.

    http://vbaccelerator.com/codelib/thread/exethr.htm
    Um americano que fala portugues.

  7. #7
    gaffa
    Guest
    Cos you've got the activex exe already, you just need to catch the events from an object array - have a look ad Edanmo's page - he has a good example of just how this is done

    www.domaindlx.com/e_morcillo

    - gaffa

  8. #8

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Doing asynchronous processing even with callbacks isn't difficult at all, just check out the coffee example from MSDN. It gives you a perfect model to use. Or even search this forum and I bet you'll find more stuff on the subject.

    The coffee example is the key though.

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