|
-
Aug 23rd, 2007, 07:01 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Creating Multithread
This is my problem to solve:
I need to download from internet various files, about 2000 per day.
I've done an app to download all this files, but it takes a lot of time to get all files because the download is done one by one, in a loop (all file names are loaded to a grid). So, I must use multi-threading.
(My app should use all band-width, but each file doesn't have more then 100kb, average 60kb).
My doubt now is: should I use a ActiveX EXE or ActiveX DLL?
After that, on project properties, which option should I choose from "Threading Model"?
Do I have to code more lines besides the download function to have multithreading?
Thank you.
-
Aug 23rd, 2007, 07:07 AM
#2
Re: Creating Multithread
ActiveX DLL doesn't do multi threading ActiveX EXE does...
Apartment threading is what VB uses
Just instantiating the ActiveX EXE gives it a new thread.
-
Aug 23rd, 2007, 08:14 AM
#3
Thread Starter
Hyperactive Member
Re: Creating Multithread
In my case, what I will do in ActiveX is a function to download 1 file.
My app will have a loop that will call the ActiveX sending the filename (as a parameter) to download the file.
Code:
Private Sub Command1_Click()
Dim ActX As New DownloaderActX.download
Dim i As Integer
For i = 1 To Me.MSHFlexGrid1.rows - 1 'All filenames in WWW are in the MSHFlexGrid
ActX Me.MSHFlexGrid1.TextMatrix(i, 1) 'send the filename to ActX EXE
Next i
End Sub
Will this be enough?
Thank you.
-
Aug 23rd, 2007, 05:35 PM
#4
Re: Creating Multithread
No, You would need to instantiate a new ActiveX exe for each download inside the loop. Something like this
Code:
Dim ActX() as DownloaderActX.download
Redim Actx(Me.MSHFlexGrid1.rows - 1)
For i = 1 To Me.MSHFlexGrid1.rows - 1 'All filenames in WWW are in the MSHFlexGrid
Set ActX(i) = New DownloaderActX.download
ActX(i) Me.MSHFlexGrid1.TextMatrix(i, 1) 'send the filename to
Next i
This would start as many downloads as you had rows. I would not recommend running that many though it is just an example.
-
Aug 23rd, 2007, 05:40 PM
#5
Thread Starter
Hyperactive Member
Re: Creating Multithread
Thank you. I'll try you tips.
-
Aug 24th, 2007, 02:55 AM
#6
Re: [RESOLVED] Creating Multithread
Don't forget to destroy each instance after it is done downloading
Code:
Set ActX(i) = Nothing
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
|