Is there a way in C# to wait until a specific task returns or timeout after a specified number of milliseconds, withOUT making all the other tasks running on the same thread be blocked as well?
Assuming you are starting the tasks individually, and not using Parallel.For/ForEach/Invoke, etc. ie You are getting a Task object back, then something like this:
Task taskIWantToWaitFor = Task.Factory.Start(....);
// Other code
taskIWantToWaitFor.Wait(millisecondsTimeout)
// All other tasks continue in the background
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.