Results 1 to 13 of 13

Thread: MultiThreading in vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    3

    MultiThreading in vb6

    I have a collection object which contains filenames of the xml file to be parsed.I need to maintain a thread pool with 5 threads and assign the filenames to the parser threads...Can anyone tell me how I can do this? Currently I am using createObject to create parserthreads and then storing the referance in an array.

    *************************
    dim mlNrTrunks as integer
    mlNrTrunks = 5
    For lInstance = 1 To mlNrTrunks
    On Error GoTo Failed
    Set MyThreadArray(lInstance) = CreateObject("MyThreads")
    GoTo Done
    Failed:
    Call Log("Thread creation failed " & Err.Number & " " & Err.Source & " " & Err.description, lInstance)
    Exit Sub
    Done:
    Next lInstance


    **********************************
    Then I am calling the parse function
    ***************************************
    lInstance =0
    Do While filename <> "_END"
    If Not MyThreadArray(lInstance).IsBusy Then
    MyThreadArray(lInstance).executeTestcase filename
    filename = getNextTestCase
    End If
    Sleep (1)
    lInstance = lInstance + 1
    If lInstance = mlNrTrunks + 1 Then
    lInstance = 1
    End If
    Loop

    ********************
    getNextTestCase returns the next filename from the collection


    Issue:

    executeTestcase is blocking...I want this call to be non blocking...I was just wondering if this can be done using non-blocking raiseEvent...First of all I am not sure if non-blocking RaiseEvent is possible in VB6....Can anyone help me plzzzzzzz

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MultiThreading in vb6

    Moved from FAQ Section

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: MultiThreading in vb6

    I could be wrong but I don't think you can multi-thread in VB6. You can create several thread-like instances but they will only run one at a time and not multi-threaded in the conventional sense (like in Java, for example).

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MultiThreading in vb6

    VB6 does not support true multithreading.

    For that, you would need to move to VB.NET

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: MultiThreading in vb6

    The only way I was ever to even come close to multi-threading in VB6 was to create a seperate application for each thread I needed to run. Of course I had to know ahead of time how many seperate threads I needed and in the main VB application launch these when called for. They communicated with each other via DDE. Quite crude and yielded many problems which I had to work out and in the end I figured it just wasn't worth it. Oh, it worked alright but didn't really match up to what you would expect in a true multi-threading application.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MultiThreading in vb6

    Wokawidget has a CodeBank entry that "simulates" multithreading. It is about a close as you are going to get with VB6.

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: MultiThreading in vb6

    I didn't know anything about Wokawidget back then when I did what I did and I still don't know what it is.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MultiThreading in vb6

    A Wokawidget is one of our members, and a member of the Mod team.

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: MultiThreading in vb6

    LOL! OK, I thought it was a thingamagig. I'll see if I can find his stuff. Thanks

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MultiThreading in vb6

    Here you go.

  11. #11
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: MultiThreading in vb6

    I've always used this and found it to be very stable across many Windows platforms:

    http://pscode.com/vb/scripts/ShowCod...26900&lngWId=1

  12. #12
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: MultiThreading in vb6

    A way is to use the BackgroundWorker facilties of .NET and build a wrapper that can be called from VB6. There's a step by step guide here: http://msdn2.microsoft.com/en-us/library/aa719109.aspx

    Of course you have to have one of the .NET compilers to make it and the NET 2 Framework. I used VB2005 Express edition (free to download and use) and it all worked OK. Not necessarily the "best" method, but once you've created the wrapper it can be reused in other VB apps.

  13. #13

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: MultiThreading in vb6

    Thanks Doogles...I am going through the article that u have mentioned...Let me check it out and revert if suits my requirement...Thanks again

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