Hi all
I'm stuck with a problem and hope someone can provide some hints on
what I'm doing wrong.
All I want to do ist start a thread which will sleep until a specified
time and then wake up and do some stuff. (see reduced-to-the-max
sample code below)
The stange thing is, it works on my developer machine (Win XP) and on a
virtual machine (Win2003 Server) I use to test, but on the "real"
server (also Win2003) RunInNewThread ist never called, also the
ThreadState is "running".
There are no exceptions, no entries in the event log.. nothing.
All machines have .NET 2.0 installed. The two working systems are
running with the default-configuration. On the target server I'm not so
sure about that, but I need to tell the administrator where to start
searching since he knows even less than I do.
Hope someone can help me on this.
TIA
Stefan
private void Test_StartThread()
{
try
{
DateTime threadStartTime = DateTime.Now.AddSeconds(30.0);
ThreadStart starter = delegate {
TestClass.RunInNewThread(threadStartTime); };
Thread t = new Thread(starter);
t.Start();
Console.Write("Thread state : " + t.ThreadState.ToString());
}
catch(Exception ex)
{
Console.Write("Starting thread falied");
}
}
public class TestClass
{
public static void RunInNewThread(DateTime pStartTime)
{
Console.Write("starting thread to run at " +
pStartTime.ToString());
// in real app, thread will sleep until pStartTime and then do some
stuff
// Thread.Sleep(pStartTime.Subtract(DateTime.Now);
//
// -- do something
}
}