public void Run() { Debug.Assert(_threadPool != null); Debug.Assert(_thread != null); // // Set the default synchronization context to allow async/await to run // continuations on the thread pool. // SynchronizationContext.SetSynchronizationContext(new ThreadPoolSynchronizationContext(_threadPool)); var threadStart = _threadPool._communicator.initializationData().threadStart; if (threadStart != null) { try { threadStart(); } catch (System.Exception ex) { string s = "thread hook start() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._communicator.Logger.error(s); } } try { _threadPool.run(this); } catch (System.Exception ex) { string s = "exception in `" + _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._communicator.Logger.error(s); } if (_observer != null) { _observer.detach(); } var threadStop = _threadPool._communicator.initializationData().threadStop; if (threadStop != null) { try { threadStop(); } catch (System.Exception ex) { string s = "thread hook stop() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._communicator.Logger.error(s); } } }
public void Run() { // // Set the default synchronization context to allow async/await to run // continuations on the thread pool. // SynchronizationContext.SetSynchronizationContext(new ThreadPoolSynchronizationContext(_threadPool)); if (_threadPool._instance.initializationData().threadHook != null) { try { _threadPool._instance.initializationData().threadHook.start(); } catch (System.Exception ex) { string s = "thread hook start() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } } try { _threadPool.run(this); } catch (System.Exception ex) { string s = "exception in `" + _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } if (_observer != null) { _observer.detach(); } if (_threadPool._instance.initializationData().threadHook != null) { try { _threadPool._instance.initializationData().threadHook.stop(); } catch (System.Exception ex) { string s = "thread hook stop() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } } }
public void Run() { if (_threadPool._instance.initializationData().threadHook != null) { try { _threadPool._instance.initializationData().threadHook.start(); } catch (System.Exception ex) { string s = "thread hook start() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } } try { _threadPool.run(this); } catch (System.Exception ex) { string s = "exception in `" + _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } if (_observer != null) { _observer.detach(); } if (_threadPool._instance.initializationData().threadHook != null) { try { _threadPool._instance.initializationData().threadHook.stop(); } catch (System.Exception ex) { string s = "thread hook stop() method raised an unexpected exception in `"; s += _threadPool._prefix + "' thread " + _thread.Name + ":\n" + ex; _threadPool._instance.initializationData().logger.error(s); } } }