each button click starting a new thread
-
Hi All, i'm trying to write a program where the button1_Click event will start a new thread and everything within the button1_Click runs within this thread, rather than starting new threads within the button1_Click. so, i want this: thrd_1 = new Thread(new ThreadStart(button1_Click)); private void button1_Click(object sender, eventArgs e) { things to do 1 things to do 2 } rather than private void button1_Click(object sender, eventArgs e) { thrd_1.start() thrd_2.start() } i hope this makes sense! Many thanks, Phil
-
Hi All, i'm trying to write a program where the button1_Click event will start a new thread and everything within the button1_Click runs within this thread, rather than starting new threads within the button1_Click. so, i want this: thrd_1 = new Thread(new ThreadStart(button1_Click)); private void button1_Click(object sender, eventArgs e) { things to do 1 things to do 2 } rather than private void button1_Click(object sender, eventArgs e) { thrd_1.start() thrd_2.start() } i hope this makes sense! Many thanks, Phil
so what exactly is your question? from what it looks like you already have the answer. Prateek
-
so what exactly is your question? from what it looks like you already have the answer. Prateek
-
Hi, thanks for replying so quickly. the problem is it won't compile. it errors saying - No overload for button1_Click matches delegate 'System.Threading.ThreadStart.
-
Hi, thanks for replying so quickly. the problem is it won't compile. it errors saying - No overload for button1_Click matches delegate 'System.Threading.ThreadStart.
The error message explains it... The ThreadStart delegate looks like this:
public delegate void ThreadStart()
Are you looking for something like this?
private void button1_Click(object sender, eventArgs e)
{
thrd_1 = new Thread(new ThreadStart(button1_Clickthread));
thrd_1.start()
}private void button1_Clickthread()
{
things to do 1
things to do 2
}Mark Salsbery Microsoft MVP - Visual C++ :java: