void CloseAndFlush() { lock (_stateLock) { if (_unloading) { return; } _unloading = true; } #if !WAITABLE_TIMER _timer.Dispose(); #else var wh = new ManualResetEvent(false); if (_timer.Dispose(wh)) { wh.WaitOne(); } #endif OnTick(); }
void CloseAndFlush() { lock (_stateLock) { if (_unloading) { return; } _unloading = true; } _timer.Dispose(); OnTick().GetAwaiter().GetResult(); }