I still think using Join is simpler. Record the expected completion time (as Now+timeout), then, in a loop, do
if(!thread.Join(End-now))
throw new NotFinishedInTime();
More Related Contents:
- Automating the InvokeRequired code pattern
- Why is Thread.Sleep so harmful
- How do I abort/cancel TPL Tasks?
- Cross-thread operation not valid [duplicate]
- Concurrent HashSet in .NET Framework?
- BackgroundWorker RunWorkerCompleted Event
- How do I run a simple bit of code in a new thread?
- C# Thread Termination and Thread.Abort()
- How to create a task (TPL) running a STA thread?
- Timeout Pattern – How bad is Thread.Abort really?
- Get list of threads
- Cannot convert lambda expression to type ‘System.Delegate’
- Why is only the UI thread allowed to modify the UI?
- c# – Volatile keyword usage vs lock
- ConfigureAwait pushes the continuation to a pool thread
- Are IEnumerable Linq methods thread-safe?
- Multi processes read&write one file
- lowering priority of Task.Factory.StartNew thread
- Thread safety for DataTable
- Accessing a form’s control from a separate thread
- Can you access UI elements from another thread? (get not set)
- Creating threads – Task.Factory.StartNew vs new Thread()
- C#/.NET analysis tool to find race conditions/deadlocks
- Run work on specific thread
- C# Windows Forms Application – Updating GUI from another thread AND class?
- Why is it a bad practice to lock the object we are going to change?
- Throwing exceptions in callback method for Timers
- Starting a new thread in a foreach loop
- How to pause/suspend a thread then continue it?
- Multithreaded NamePipeServer in C#