private void ExecuteScenarioThreadFunction() { try { _work.Init(); Initialized = true; OnThreadInitialized(); _prewait.Wait(ref _stopQueued); if (!_stopQueued) { _work.Execute(ref _stopQueued); } } catch (Exception ex) { OnThreadError(ex); } finally { try { _work.Cleanup(); } catch (Exception ex) { OnThreadError(ex); } OnThreadFinished(); } }