T
TampaWebDevelopment
I am writing a FTP backup service for my servers. Right now, it works
well, but it is single threaded and takes a couple of hours to
complete a backup of the websites directory, even to a server on the
same network. I want to spin off 8 threads to handle the uploading.
When one files is finished uploading, a thread becomes available and a
new one is opened.
So, say that I have the following code..... This is just Pseudo
Code...
For x As Integer = 0 To UBound(arrayOfFiles)
'-- Old Code Here Was Something Like This.....
'-- ftpConnection.UploadFile(arrayOfFiles(x), strRemotePath)
'-- What I want to do here is just continue with this single thread
and just add all these to a Queue....
'-- I will then have a System.Timers.Timer look for items in the
global queue and upload them..
'-- So, I wrote my own queue, inheriting from a something in
System.Collections and my new code will be like this..
Queue.Add(arrayOfFiles(x), strRemotePath)
Next
The question is... What should my code look like in the Timer? I think
I might need to use some Events and Delegates, maybe a custom event
like Queue.Item(x).UploadFile ???
I just need a little sample on multi-threading for this type of
purpose and I am good. All the samples that I have found thus far are
either junk code, or just didn't fit into what I was trying to
accomplish.
Any help is appreciated. Thanks.
well, but it is single threaded and takes a couple of hours to
complete a backup of the websites directory, even to a server on the
same network. I want to spin off 8 threads to handle the uploading.
When one files is finished uploading, a thread becomes available and a
new one is opened.
So, say that I have the following code..... This is just Pseudo
Code...
For x As Integer = 0 To UBound(arrayOfFiles)
'-- Old Code Here Was Something Like This.....
'-- ftpConnection.UploadFile(arrayOfFiles(x), strRemotePath)
'-- What I want to do here is just continue with this single thread
and just add all these to a Queue....
'-- I will then have a System.Timers.Timer look for items in the
global queue and upload them..
'-- So, I wrote my own queue, inheriting from a something in
System.Collections and my new code will be like this..
Queue.Add(arrayOfFiles(x), strRemotePath)
Next
The question is... What should my code look like in the Timer? I think
I might need to use some Events and Delegates, maybe a custom event
like Queue.Item(x).UploadFile ???
I just need a little sample on multi-threading for this type of
purpose and I am good. All the samples that I have found thus far are
either junk code, or just didn't fit into what I was trying to
accomplish.
Any help is appreciated. Thanks.