Results 1 to 6 of 6

Thread: [RESOLVED] Creating Multithread

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [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.

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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.

  3. #3

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    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.

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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.

  5. #5

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Creating Multithread

    Thank you. I'll try you tips.

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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
  •  



Click Here to Expand Forum to Full Width