To pass a parameter to a method via a thread like this, I think you need to use a 'ParameterizedThreadstart' delegate instead of a ThreadStart.
You need to pass an object to the thread via the call to .start the thread, and then cast it to the type you want to use inside your method.
Something like this:
Code:private void button1_Click(object sender, EventArgs e) { string textTosay = "abc"; Thread newThread = new Thread(new ParameterizedThreadStart(Work)); newThread.Start(textTosay); } private void Work(object state) { string say = state as string; MessageBox.Show(say); }





Reply With Quote