So...what happens? Is an error thrown? I'm assuming from what you've said, nothing happens.
Printable View
So...what happens? Is an error thrown? I'm assuming from what you've said, nothing happens.
Yeah, nothing happens and no errors are thrown.
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
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?
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.
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?
How big is the file you're downloading?
It is 6,420 KB and an mp3 file.
The server you're getting it from, does it allow files to be downloaded with out credentials?
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
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.
Excuse the double post, but I have released a new version that has some moderate changes and with more to come.
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.
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.
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
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.
I am though getting an error still inside this,Code:Public Sub OnMyEvent(ByVal sender As Object, ByVal e As ASQS.ManagerClass.FileCompletionArgs) Handles asdf.ProgressFinished
MsgBox(e.FileName)
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)
Else
RaiseEvent ProgressFinished(Data.FileName)
End If
Downloading = False
SpeedCalculate.Stop() 'this line is highlighted with error dialog
GC.Collect()
End Sub
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
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.
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
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.
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
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.
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.
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.
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.