Page 2 of 2 FirstFirst 12
Results 41 to 71 of 71

Thread: Asynchronous File Downloading Queue System

  1. #41

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    So...what happens? Is an error thrown? I'm assuming from what you've said, nothing happens.

  2. #42
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    Yeah, nothing happens and no errors are thrown.

  3. #43

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Try doing this...

    Code:
    Private Delegate Sub d_ChangeLabel(ByVal text As String)
    Private Sub ChangeLabel(ByVal text As String)
        If Label1.InvokeRequired Then
            Label1.Invoke(New d_ChangeLabel(AddressOf ChangeLabel), text)
        Else
            Label1.Text = text
        End If
    End Sub
     
        Private Sub sas_DownloadProgressChanged(ByVal file As String, ByVal speed As String, ByVal percent As Integer) Handles sas.ProgressChanged
            Call ChangeLabel(speed)
        End Sub

  4. #44
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    I just tried that and nothing still. I'm just making a reference to the ASQS.dll trying this and was wondering if I'm suppose to add the actual ASQS project(downloadclass.vb, filestructure.vb..) to this project and delete the reference?

  5. #45

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Did you try stepping through it to see if things were actually being processed? Try calling the Runlist() method anyway, just in case setting AutoDownload to true didn't work.

  6. #46
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    I tried calling just the runlist() instead and still nothing. I tried stepping through and end up at this inside downloadclass.vb with it only stepping through

    Dim CurBytes As Long = e.BytesReceived
    Dim StreamEnd As Long = e.TotalBytesToReceive
    If SpeedCalculate.Elapsed.TotalSeconds > 0 Then

    and then jumping to

    End

    The download finishes but if I keep stepping through it repeats the above jumping. Is it suppose to jump from If SpeedCalculate.Elapsed.TotalSeconds > 0 Then to End while a file is downloading or is there something wrong with the speedcalculate stopwatch?

  7. #47

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    How big is the file you're downloading?

  8. #48
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    It is 6,420 KB and an mp3 file.

  9. #49

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    The server you're getting it from, does it allow files to be downloaded with out credentials?

  10. #50
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    I have no idea but I just tried again on a different file which is some indie game I found that is bigger in size(19,744 kb) for testing and still nothing.

    EDIT: here is the game download link, http://www.nomoresweden.com/files/manenough.zip , are you sure the SpeedCalculate.Elapsed.TotalSeconds has nothing to do with the progress not being shown?

    EDIT: I also added a watch to SpeedCalculate.Elapsed.TotalSeconds and it stays 0.0 for the value while the file is downloading..

    EDIT: I added this to the DownloadClass.vb and compiled a new ASQS.dll. I'm not sure if that is exactly where I should start the SpeedCalculate though, but the progress change event worked for getting speed. I'll have to try another step through I guess..

    Code:
        Public Sub Start()
            If Not Downloading Then
                WC.DownloadFileAsync(New Uri(Data.URL), Data.SaveTo)
                Downloading = True
                SpeedCalculate.Start() 'added this line
            End If
        End Sub
    Last edited by Grebo; Jul 15th, 2010 at 08:23 PM.

  11. #51

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    I'm quite surprised I missed that. I'll look over the code (I'm doing a rewrite as I type this) to make sure that's where that should go. If so, thanks for pointing this out and I'm surprised that this hasn't caused an issue beforehand.

  12. #52

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Excuse the double post, but I have released a new version that has some moderate changes and with more to come.

  13. #53
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    How would I handle the ProgressFinished event for example with this new event patterns change and what are the advantages? Thanks

    EDIT: Do you know how or what would be easiest method for determining which file has has finished downloading from a listview item using this class. I'm been wondering how exactly I am going to do this because I'll be tagging each mp3 when they are finished downloading but seems like it going to a very complicated process.
    Last edited by Grebo; Jul 18th, 2010 at 04:59 PM.

  14. #54

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    The advantages is that instead of one long signature, you get a signature that's two objects max, the 1st being the sender, and the 2nd being an organized structure that contains all the information you need.

    As for your 2nd question, override the OnFileCompletion() sub, you can do your tagging in there if the file is an MP3.

  15. #55
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    Sorry for so many questions but the switch hasn't been fun. I am not sure if I'm actually doing this correctly but the msgbox shows twice and I get an error while debugging with the error "Object reference not set to an instance of an object." on this line SpeedCalculate.Stop() inside Private Sub WC_DownloadFileCompleted (DownLoadClass.vb) . I'm not sure also on how to get file, speed and percent correctly with the changes. Thanks

    Code:
    Imports ASQS
    Public Class Form1
        Public WithEvents asdf As New ManagerClass
        Public Delegate Sub prog_event(ByVal sender As Object, ByVal e As ASQS.ManagerClass.ProgressEventArgs)
    
        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim test As FileData
    
            asdf.AutoDownload = True
            'asdf.MaxDownloads = 2
    
            test.SaveTo = "C:\Downloads\test.mp3"
            test.URL = "http://www.site.com/themp3.mp3"
            'MsgBox(test.FileName)
            'MsgBox(test.FilePath)
    
            asdf.Add(test)
            AddHandler asdf.ProgressFinished, AddressOf OnMyEvent
        End Sub
        Public Sub OnMyEvent(ByVal sender As Object, ByVal e As ASQS.ManagerClass.FileCompletionArgs) Handles asdf.ProgressFinished
            RemoveHandler asdf.ProgressFinished, AddressOf OnMyEvent
            MsgBox("done")
        End Sub
        Public Sub OnMyEvent2(ByVal sender As Object, ByVal e As ASQS.ManagerClass.ProgressEventArgs) Handles asdf.ProgressChanged
            Try
                If Me.InvokeRequired Then
                    Me.Invoke(New prog_event( _
                    AddressOf OnMyEvent2 _
                    ), New Object() {percent}, {speed})
                Else
                    Me.ProgressBar1.Value = percent
                    Me.Label1.Text = speed
                End If
            Catch ex As Exception
                MsgBox(ex.Message & vbCrLf & ex.StackTrace)
            End Try
        End Sub
    End Class

  16. #56
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    I'm still not quite sure how I am suppose to match all the tags/picture.jpg with the mp3 that has finished downloading because if I am going with the multiple download option I could get a third mp3 file finishing before the first and so on..

    Never mind about not being able to get speed, file and filename correctly, I figured it out and it is easier than I thought.

    Code:
        Public Sub OnMyEvent(ByVal sender As Object, ByVal e As ASQS.ManagerClass.FileCompletionArgs) Handles asdf.ProgressFinished
            MsgBox(e.FileName)
        End Sub
    I am though getting an error still inside this,

    Code:
        Private Sub WC_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WC.DownloadFileCompleted
            If e.Error IsNot Nothing Then
                RaiseEvent FileError(Data.FileName, e.Error)
            Else
                RaiseEvent ProgressFinished(Data.FileName)
            End If
            Downloading = False
            SpeedCalculate.Stop() 'this line is highlighted with error dialog
            GC.Collect()
        End Sub
    and I believe it could be avoided using something like this? ..

    Code:
        Private Sub WC_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WC.DownloadFileCompleted
            If e.Error IsNot Nothing Then
                RaiseEvent FileError(Data.FileName, e.Error)
            End If
            Downloading = False
            RaiseEvent ProgressFinished(Data.FileName)
            If SpeedCalculate IsNot Nothing Then
                SpeedCalculate.Stop()
                SpeedCalculate = Nothing
            End If
            GC.Collect()
        End Sub

  17. #57

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    You can do that work around, I'm not sure why it's still throwing that though...I'll investigate it more. Thank you for the feedback and sorry that I didn't reply to your previous one. I have been a bit busy recently with other things.

  18. #58
    Member
    Join Date
    Oct 2007
    Posts
    34

    Re: Asynchronous File Downloading Queue System

    Formlesstree4, can you give me example on how I could populate a listview with the filename, percentage, and speed for each download in the currentdownlist? I'm going to use a dictionary to store data for tagging with the filename being the key to look for in the dictionary when the file has finished downloading for tagging. Thanks,
    Grebo

  19. #59

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Perhaps when I fully finish with my class, I can do that. I'm still working on tweaking things here and there, adding new events and what not.

  20. #60
    Member
    Join Date
    Sep 2010
    Posts
    41

    Re: Asynchronous File Downloading Queue System

    this is great wrk formlesstree.

    im new to vb and i dont know how to get this to work. can you show me a example?

    i have 5 files i want to download and i want to display a progressbat. i added the queuesystem.vb file to my project and i imported the namespace, but i don't know how to use the class. it would be very helpful if you could add an example to your first post.

    thx

  21. #61

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    So you're using the original version, not the multiple downloading version, correct? As I said in post #59, I'll get some examples up eventually. If someone else were to write examples using the class, that's fine too, I'm just to busy right now to get an example application running.

  22. #62
    Member
    Join Date
    Sep 2010
    Posts
    41

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by formlesstree4 View Post
    So you're using the original version, not the multiple downloading version, correct? As I said in post #59, I'll get some examples up eventually. If someone else were to write examples using the class, that's fine too, I'm just to busy right now to get an example application running.
    i think i'm using the multiple downloading version. at least i want to.

    what i'm asking i thought should be too hard to make. i just need to add urls to queue and then download w/ progressbar.

  23. #63

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by JohnDorian View Post
    i think i'm using the multiple downloading version. at least i want to.

    what i'm asking i thought should be too hard to make. i just need to add urls to queue and then download w/ progressbar.
    It's not, the class isn't difficult to use. The version you're using, if you just downloaded the .VB file, is one that queues files and downloads them one at a time rather than simultaneously. Just create a new instance of the class and Add items to the queue. If you read the .VB file, you'll understand exactly what to do as I'm pretty sure I commented everything there.

  24. #64
    Member
    Join Date
    Sep 2010
    Posts
    41

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by formlesstree4 View Post
    It's not, the class isn't difficult to use. The version you're using, if you just downloaded the .VB file, is one that queues files and downloads them one at a time rather than simultaneously. Just create a new instance of the class and Add items to the queue. If you read the .VB file, you'll understand exactly what to do as I'm pretty sure I commented everything there.
    But what about the progressbar?

    i did what you said and i had no problem with downloading, but i dont know how to get progress. i look into the class comments like you suggested.

  25. #65

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by JohnDorian View Post
    But what about the progressbar?

    i did what you said and i had no problem with downloading, but i dont know how to get progress. i look into the class comments like you suggested.
    There is a specific event that is raised which gives the progress for the file currently being downloaded. I'm not sure which one it is right now..but it is in there.

  26. #66
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    300

    Re: Asynchronous File Downloading Queue System

    I'm sorry if this is too old to be bumped, I'm kind of new.

    I'm using the Demo to test out how it works. When I add the download to queue, Nothing happens. Stays the same at 0% precent. Nothing.

  27. #67

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by Xoslize View Post
    I'm sorry if this is too old to be bumped, I'm kind of new.

    I'm using the Demo to test out how it works. When I add the download to queue, Nothing happens. Stays the same at 0% precent. Nothing.
    What's the file you're trying to download?

  28. #68
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    300

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by formlesstree4 View Post
    What's the file you're trying to download?
    A direct link, a rar file. Anything I tried doesn'ts eem to wrok.

  29. #69

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by Xoslize View Post
    A direct link, a rar file. Anything I tried doesn'ts eem to wrok.
    I can't remember if you're supposed to start it or if it downloads automatically...I'll look into it when I get some time.

  30. #70
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    300

    Re: Asynchronous File Downloading Queue System

    Quote Originally Posted by formlesstree4 View Post
    I can't remember if you're supposed to start it or if it downloads automatically...I'll look into it when I get some time.
    What's the code to start downloading all the queue? Because your code to add it to the queue and the checkbox to auto download is missing code.

  31. #71
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: Asynchronous File Downloading Queue System

    Great work there!

    Nice class, just downloaded the project and checking it out.

    What i would suggest is to add Remaining Time, Downloaded so far and Time remaining columns.
    Thanks for helping me out.

Page 2 of 2 FirstFirst 12

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