why are you using seperate threads for each image to upload. Threading is good concept but they add overhead to the system also Programming and debugging becore more complex.
Can you show me a sample of your code so as i can understand what kind of threading you are using ?
IAM USING FOLLOWING CODE:
Thread[] aoThread = new Thread[nFileCount];//Here nFileCount is total number of files
for (int i= 0; nThread < nFileCount; i++)
{
aoThread[nThread]=new Thread(UploadMultipleFiles);
aoThread[i].Start(aostrFiles[i]); //aostrFiles is array of file path
}
public void UploadMultipleFiles(object filePath)
{
}
}
In above code thread created =no of file uploading
But i want to maximum 3 thread create and file number more than 3 assign task to free thread
info2ambrish
Member
385 Points
275 Posts
Thrading in c#
Feb 24, 2012 08:21 AM|LINK
Hi All
I am using two thread for uploading the files.
Ex:
I have total file f1 f2 f3 f4
Thread1 ----------upload file f1
Thread2------------upload file f2
how to check thread1 or thread2 finish the upload to assign new file upload f3 or f4.
Pleae provide some code.
Thanks in advance
Muhammad Fak...
Contributor
2268 Points
511 Posts
Re: Thrading in c#
Feb 24, 2012 08:40 AM|LINK
Can you show me a sample of your code so as i can understand what kind of threading you are using ?
If you feel it helps, Mark as answered so that it can help others to find solution.
For Any further questions, please contact me.
rohitpundlik
Contributor
3102 Points
945 Posts
Re: Thrading in c#
Feb 24, 2012 08:44 AM|LINK
Check below resolved thread...
http://forums.asp.net/t/1758047.aspx/1
Rohit Pundlik
Please mark as answer if this helps you...
santosh.jagd...
Star
7625 Points
1454 Posts
Re: Thrading in c#
Feb 24, 2012 08:48 AM|LINK
why are you using seperate threads for each image to upload. Threading is good concept but they add overhead to the system also Programming and debugging becore more complex.
if possible use one thread to upload all images.
MCP
shashankgwl
All-Star
18926 Points
3662 Posts
Re: Thrading in c#
Feb 24, 2012 08:50 AM|LINK
you can call Thread1.Join and Thread2.Join() to wait untill they complete.
All is well if it runs well.
blog
info2ambrish
Member
385 Points
275 Posts
Re: Thrading in c#
Feb 24, 2012 08:52 AM|LINK
IAM USING FOLLOWING CODE:
Thread[] aoThread = new Thread[nFileCount];//Here nFileCount is total number of files for (int i= 0; nThread < nFileCount; i++) { aoThread[nThread]=new Thread(UploadMultipleFiles); aoThread[i].Start(aostrFiles[i]); //aostrFiles is array of file path } public void UploadMultipleFiles(object filePath) { } }info2ambrish
Member
385 Points
275 Posts
Re: Thrading in c#
Feb 24, 2012 08:55 AM|LINK
I did following code but not working:
Thread[] aoThread = new Thread[nFileCount]; for (int i = 0; i < nFileCount; i++) { for (int nThread = 0; nThread < 2; nThread++) { aoThread[nThread]=new Thread(UploadMultipleFiles); aoThread[nThread].Start(aostrFiles[i]); } for (int nJoin = 0; nJoin < 2; nJoin++) { if(!aoThread[nJoin].IsAlive) aoThread[nJoin].Join(); } }shashankgwl
All-Star
18926 Points
3662 Posts
Re: Thrading in c#
Feb 24, 2012 09:01 AM|LINK
What is that code doing? calling join when thread is dead?
All is well if it runs well.
blog
info2ambrish
Member
385 Points
275 Posts
Re: Thrading in c#
Feb 24, 2012 09:25 AM|LINK
How to start same thread for next fileupload.Can you modify above code that active for next file.
shashankgwl
All-Star
18926 Points
3662 Posts
Re: Thrading in c#
Feb 24, 2012 10:29 AM|LINK
why are you creating threads in loop if you wan't only one thraed to process the file upload work?
All is well if it runs well.
blog