4 using System.Threading.Tasks;
16 private bool _workerThreadRunning =
false;
17 private Exception _savedException;
21 _workerThreadRunning =
true;
24 Task.Factory.StartNew(() =>
26 ThreadPool.QueueUserWorkItem((_) =>
38 _workerThreadRunning =
false;
43 if (_savedException != null)
45 throw _savedException;
49 private IEnumerator Wait()
51 while (_workerThreadRunning)
Creates a thread to run multithreaded operations on
IEnumerator RunOnWorkerThread(Action action)