Z
Zippy
I've got a problem starting a thread in c#.
Two scenarios.
1) got a form, which creates an instance of a class. in the
constructor of the class is a call to a method which starts a thread.
public void StartThread ()
{
new Thread (new ThreadStart (this.WaitExecute)).start();
Console.WriteLine ("thread started")
}
private void WaitExecute()
{
Console.WriteLine ("thread sleep");
Thread.Sleep (30000);
SignOn();
this.Invoke (new EventHandler (this.Restart));
Console.WriteLine ("thread done");
}
this works.
scenario 2
send 2 msmq messages (send 1 and its fine) and the thread doesnt start
ie all i get on the console is the "thread started" message and not
the "thread sleep"
the msmq call was originally in the same class as the thread above,
but i've since move it ot its own class.
i have also now moved the call to the startThread onto a button on the
main form
i can send one message and the click on the button and it starts fine
send two messages and the thread wont start.
any ideas would be appreciated
Andy
Two scenarios.
1) got a form, which creates an instance of a class. in the
constructor of the class is a call to a method which starts a thread.
public void StartThread ()
{
new Thread (new ThreadStart (this.WaitExecute)).start();
Console.WriteLine ("thread started")
}
private void WaitExecute()
{
Console.WriteLine ("thread sleep");
Thread.Sleep (30000);
SignOn();
this.Invoke (new EventHandler (this.Restart));
Console.WriteLine ("thread done");
}
this works.
scenario 2
send 2 msmq messages (send 1 and its fine) and the thread doesnt start
ie all i get on the console is the "thread started" message and not
the "thread sleep"
the msmq call was originally in the same class as the thread above,
but i've since move it ot its own class.
i have also now moved the call to the startThread onto a button on the
main form
i can send one message and the click on the button and it starts fine
send two messages and the thread wont start.
any ideas would be appreciated
Andy