|
-
May 19th, 2013, 12:02 PM
#1
Thread Starter
New Member
multiupload thread queue
Hi, I'm just a newbie and try to do mutltiupload to a php script.
My app talk to an external app
This external app put some files in a backup directory and send to my app a signal alet
My app receive this signal (a specific message) via the Overrides Sub WndProc()
When I receive the message, I know that there is a file to upload to my webserver.
Code:
Sub WndProc()
......
ThreadPool.QueueUserWorkItem(AddressOf AutoUpload, upldData)
...... end sub
Code:
delegate D_AutoUpload(dt as object)
sub AutoUpload(dt as object)
.......
StatusCode = upload(filepath, UrlWebsite)
if statuscode = "OK" then
deleteFile(filepath) end if
...... end sub
Code:
Function upload(filepath as string, UrlWebsite as string)
.......
.......(upload & update a progressBar)
.......
Return statusCode end sub
A upload maybe a little bit longer and sometimes I have to upload another one before my previous file is completed.
Because I receive several signals alert in 5 or 10sec and a upload is about 10sec to 2mins by file.
I must upload all files one by one in the correct order.
I would like to wait the previous upload accomplished before to upload the next one.
I think, I have to use thread, queue, maybe threadpool but don't have any Idea.
If someone could tell me how to do, It will be very appreciated.
Thanks in advance
Isa
-
May 19th, 2013, 02:14 PM
#2
Re: multiupload thread queue
Well, what you could do is instead of having your overriden WndProc do the uploads itself, you add it to a list and have a separate thread enumerate this list one by one and upload each file.
-
May 19th, 2013, 03:25 PM
#3
Thread Starter
New Member
Re: multiupload thread queue
Hi Niya,
Thanks fer answer.
I need to upload in real time.
Each time a file is placed in the folder, I have to upload this file to my webserver.
I use WndProc to trigger my upload.
When a file is placed on the backup directory, immediatly, my application receive a message via the WndProc.
From WndProc I call my function (AutoUpload).
And sometimes I receive 3 or more messages (3 files or more in the backup directory) in few seconds.
I can not upload all files at the same time. Only 1 by 1. How to do. I think I have to declare a queue or something like that. (enqueue, dequeue)
But I don't know exactly how to do the nexts steps with the threads.
Isa
-
May 20th, 2013, 11:35 AM
#4
Re: multiupload thread queue
If you can't upload simultaneously then it really doesn't make any sense to create a new thread for each file at all. It would be much easier all round if you had one upload thread accessing a list of filenames. Your update process adds new files to the list. The upload thread can run on a loop, checking the list, uploading any file in the list then removing it from the list. If after this there remain items on the list upload the next, if not sleep for whatever period is appropriate.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
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
|