protected SingleThreadWorker() { _Core = CoreBinder.Allocate(); _Priority = ThreadPriorityLevel.Normal; _thread = new Thread(_Run); _thread.IsBackground = true; _thread.Start(); }
private void _Run() { if (_Core != 0) { CoreBinder.Bind(_Core, _Priority); } while (!IsDisposed) { if (!BusySpin) { _mre_work.Wait(); _mre_work.Reset(); } if (!_jobs.IsEmpty) { while (_jobs.TryDequeue(out T tpl)) { try { DoWork(tpl); } catch (Exception ex) { if (CrashOnExcept) { throw new Exception("STE Crash: " + GetType(), ex); } var e = new ExceptionEventArgs(ex); GlobalExceptionThrown?.Invoke(this, e); InstanceExceptionThrown?.Invoke(this, e); } } } } _mre_dispose.Set(); }