Can't suspend a thread

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
 
E

emr

solved the problem but a new one :(

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

it prints unstarted ??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top