I\'m new to threading in C#. Is there anyway of setting a timeout for a thread without blocking the calling thread (in C# 3.5)?
If not, is it logical to execute a fu
Look at WaitHandle.WaitOne() method with the middleObject scheme.
Public void main()
{
...
middleObj.WaitHandle.Reset();
Thread thrd1 = new Thread(new ThreadStart(middleObj.waiter));
thrd1.Start();
middleObj.WaitHandle.WaitOne(timeout);
...
}
//And in the middleObj.waiter():
Public void waiter()
{
Thread thrd2 = new Thread(new ThreadStart(targetObj.targetFunc));
thrd2.Start();
thrd2.Join();
this.WaitHandle.Set();
}
Not sure what would happen to the unfinished thread, though.