I am trying to reproduce a threading error condition within an HTTP Handler.
Basically, the ASP.net worker procecss is creating 2 threads which invoke the HTTP hand
You could just set a static time to start your work like this.
private static DateTime startTime = DateTime.Now.AddSeconds(5); //arbitrary start time
static void Main(string[] args)
{
ThreadStart threadStart1 = new ThreadStart(DoSomething);
ThreadStart threadStart2 = new ThreadStart(DoSomething);
Thread th1 = new Thread(threadStart1);
Thread th2 = new Thread(threadStart2);
th1.Start();
th2.Start();
th1.Join();
th2.Join();
Console.ReadLine();
}
private static void DoSomething()
{
while (DateTime.Now < startTime)
{
//do nothing
}
//both threads will execute code here concurrently
}