|
-
Feb 25th, 2008, 06:37 AM
#1
Thread Starter
New Member
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
-
Feb 25th, 2008, 06:50 AM
#2
Re: MultiThreading in vb6
-
Feb 25th, 2008, 12:37 PM
#3
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).
-
Feb 25th, 2008, 12:43 PM
#4
Re: MultiThreading in vb6
VB6 does not support true multithreading.
For that, you would need to move to VB.NET
-
Feb 25th, 2008, 01:01 PM
#5
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.
-
Feb 25th, 2008, 01:05 PM
#6
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.
-
Feb 25th, 2008, 01:47 PM
#7
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.
-
Feb 25th, 2008, 01:57 PM
#8
Re: MultiThreading in vb6
A Wokawidget is one of our members, and a member of the Mod team.
-
Feb 25th, 2008, 02:13 PM
#9
Re: MultiThreading in vb6
LOL! OK, I thought it was a thingamagig. I'll see if I can find his stuff. Thanks
-
Feb 25th, 2008, 02:31 PM
#10
Re: MultiThreading in vb6
-
Feb 25th, 2008, 11:47 PM
#11
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
-
Feb 26th, 2008, 12:15 AM
#12
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.
-
Feb 26th, 2008, 01:07 AM
#13
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|