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:
- Create Dynamic Threads in c# [closed]
- 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?
- Can a C# thread really cache a value and ignore changes to that value on other threads?
- Have a set of Tasks with only X running at a time
- BackgroundWorker RunWorkerCompleted Event
- How do I run a simple bit of code in a new thread?
- C# Thread Termination and Thread.Abort()
- C#: Waiting for all threads to complete
- How to protect resources that may be used in a multi-threaded or async environment?
- Cancelling a pending task synchronously on the UI thread
- Set timeout to an operation
- What is a thread exit code?
- Does using Tasks (TPL) library make an application multithreaded?
- Why is only the UI thread allowed to modify the UI?
- lock keyword in C#
- Wait for a while without blocking main thread
- Workaround for the WaitHandle.WaitAll 64 handle limit?
- Can you access UI elements from another thread? (get not set)
- Progress Bar not available for zipfile? How to give feedback when program seems to hang
- Getting Cross-thread operation not valid [duplicate]
- Show Loading animation during loading data in other thread
- C# Windows Forms Application – Updating GUI from another thread AND class?
- What is the difference between .Wait() vs .GetAwaiter().GetResult()?
- ReaderWriterLock vs lock{}
- How to work threading with ConcurrentQueue
- Guidelines of when to use locking