-
Jul 15th, 2010, 01:40 PM
#41
Re: Asynchronous File Downloading Queue System
So...what happens? Is an error thrown? I'm assuming from what you've said, nothing happens.
-
Jul 15th, 2010, 01:59 PM
#42
Member
Re: Asynchronous File Downloading Queue System
Yeah, nothing happens and no errors are thrown.
-
Jul 15th, 2010, 02:05 PM
#43
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
-
Jul 15th, 2010, 04:16 PM
#44
Member
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?
-
Jul 15th, 2010, 04:17 PM
#45
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.
-
Jul 15th, 2010, 04:52 PM
#46
Member
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?
-
Jul 15th, 2010, 05:01 PM
#47
Re: Asynchronous File Downloading Queue System
How big is the file you're downloading?
-
Jul 15th, 2010, 05:04 PM
#48
Member
Re: Asynchronous File Downloading Queue System
It is 6,420 KB and an mp3 file.
-
Jul 15th, 2010, 05:05 PM
#49
Re: Asynchronous File Downloading Queue System
The server you're getting it from, does it allow files to be downloaded with out credentials?
-
Jul 15th, 2010, 05:15 PM
#50
Member
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.
-
Jul 18th, 2010, 03:54 AM
#51
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.
-
Jul 18th, 2010, 04:11 AM
#52
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.
-
Jul 18th, 2010, 04:51 PM
#53
Member
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.
-
Jul 18th, 2010, 08:52 PM
#54
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.
-
Jul 19th, 2010, 12:18 AM
#55
Member
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
-
Jul 20th, 2010, 03:50 AM
#56
Member
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
-
Jul 20th, 2010, 01:02 PM
#57
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.
-
Jul 28th, 2010, 06:33 PM
#58
Member
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
-
Jul 29th, 2010, 03:02 AM
#59
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.
-
Sep 19th, 2010, 03:53 PM
#60
Member
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
-
Sep 19th, 2010, 05:03 PM
#61
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.
-
Sep 19th, 2010, 06:14 PM
#62
Member
Re: Asynchronous File Downloading Queue System
Originally Posted by formlesstree4
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.
-
Sep 19th, 2010, 07:21 PM
#63
Re: Asynchronous File Downloading Queue System
Originally Posted by JohnDorian
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.
-
Sep 19th, 2010, 07:52 PM
#64
Member
Re: Asynchronous File Downloading Queue System
Originally Posted by formlesstree4
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.
-
Sep 19th, 2010, 08:06 PM
#65
Re: Asynchronous File Downloading Queue System
Originally Posted by JohnDorian
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.
-
Dec 9th, 2011, 01:30 PM
#66
Hyperactive Member
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.
-
Dec 10th, 2011, 12:41 AM
#67
Re: Asynchronous File Downloading Queue System
Originally Posted by Xoslize
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?
-
Dec 10th, 2011, 03:53 AM
#68
Hyperactive Member
Re: Asynchronous File Downloading Queue System
Originally Posted by formlesstree4
What's the file you're trying to download?
A direct link, a rar file. Anything I tried doesn'ts eem to wrok.
-
Dec 10th, 2011, 01:12 PM
#69
Re: Asynchronous File Downloading Queue System
Originally Posted by Xoslize
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.
-
Dec 10th, 2011, 01:21 PM
#70
Hyperactive Member
Re: Asynchronous File Downloading Queue System
Originally Posted by formlesstree4
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.
-
May 19th, 2013, 09:31 PM
#71
Hyperactive Member
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.
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
|