473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

creating multiple instance of same thread

42
hi all,
can any one help me to create multiple instance of a thread?
here what i'm doing is that , i want to upload a file from my c# windows application, once i put it for upload i want to continue uploading another, so and so
here what i did is on each button click i created a thread that handles the file uploading

Expand|Select|Wrap|Line Numbers
  1. public....Button_click()
  2. {
  3. Thread t2 = new Thread(new ThreadStart(DoStuff));
  4.             t2.IsBackground = true;
  5.             t2.Start();
  6. }
if it is for once it works fine, but if i try to upload another file using the same procedure it makes my 1st thread to stop.
i kno this is not the way to do this stuff, please some one help.
Feb 11 '09 #1
2 2335
PRR
750 Expert 512MB
Can you explain more ? what error are you getting? in my opinion it should not make the thread stop... unless there is some exception thrown... in that case the thread will abort .... If you are trying to access the same file then i guess you may get access denied error ...
For short background task you can always use ThreadPool.QueueUserWorkItem threads... Background thread are more efficient
Feb 11 '09 #2
libish
42
here i have a form which browses a file, and after browsing i need to upload this file to an ftp server, here once i selected the file and click upload the action i written is like this

Expand|Select|Wrap|Line Numbers
  1. public....Button_click() 
  2. Thread t2 = new Thread(new ThreadStart(DoStuff)); 
  3.             t2.IsBackground = true; 
  4.             t2.Start(); 
here do stuff method will handle the upload fn.
and nw i went to browse another file, and then i click upload, so the control once again gets into the method above

Expand|Select|Wrap|Line Numbers
  1. public....Button_click() 
  2. Thread t2 = new Thread(new ThreadStart(DoStuff)); 
  3.             t2.IsBackground = true; 
  4.             t2.Start(); 
here whn control enters into it the 1st thread terminates...

can u help me now???


i tried ThreadPool.QueueUserWorkItem as below

Expand|Select|Wrap|Line Numbers
  1. bool ab = ThreadPool.QueueUserWorkItem(new WaitCallback((DoStuff)));
still the same probblm exist

can u suggest me a way out.
i think itz because of the way i'm using the methods... can u help me nw?
Feb 11 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
4
by: Gregory Gadow | last post by:
I've cobbled together a PrinterClass that takes a text file and dumps it to a printer. The app using is has multiple threads, all of which need access to a shared instance. Can someone point me to...
3
by: Michel | last post by:
Hi, I wrote an app in .Net and I whant only 1 instance of this app open for the user; the user open my app, do some works and try to open another instance of my app, I whant to show a message to...
5
by: Bob Bins | last post by:
Is there a way to create a shared lock using the Monitor class or any other synchronization class in .NET? So I have one resource that may have multiple threads using it at once but a second...
0
by: rbg | last post by:
Have a web application which uses Data Cache. I need to understand what happens when a new instance of the same web application is created for for serving concurrent clients. What happens when...
5
by: dk60 | last post by:
Here is a problem I encountered concerning threads: Here is the code in Form1 button click handler: AddForm addForm = new AddForm(booksDataSet.Titles); Thread addTitleThread=new Thread(new...
5
by: pgrazaitis | last post by:
I cant seem to get my head wrapped around this issue, I have myself so twisted now there maybe no issue! Ok so I designed a class X that has a few members, and for arguments sake one of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.