Can't suspend a thread

  • Thread starter Thread starter emr
  • Start date Start date
E

emr

Hi there, here is the situation:

private void btnStart_Click(object sender, System.EventArgs e)

{

if(btnStart.Text=="START")

{

Thread connect=new Thread(new ThreadStart(Connect2Server));

connect.Start();

}

if(btnStart.Text=="STOP")

{

connect.Suspend(); // An unhandled exception of type
'System.NullReferenceException' occurred in .exe Additional information:
Object reference not set to an instance of an object.

btnStart.Text="RESUME";

.....

thank you
 
solved the problem but a new one :(

connect.Start(); //everything ok it does whatever i want//
lstResult.Items.Add(connect.ThreadState);

it prints unstarted ??
 
Back
Top