private void Start() { lock (_syncRoot) { if (_isActive) { return; } var buffer = CreateAsyncBuffer(); buffer.BufferReady += (s, e) => NotifyBufferReady(); _asyncBuffer = buffer; _isStopRequest = false; _isStopReceived = false; _isActive = true; _thread = CreateThread(FlushThreadProc); _thread.Start(); } }
private void Stop() { lock (_syncRoot) { if (!_isActive) { return; } _isStopRequest = true; SendAsync(_stopEvent, true); _flushEvent.Set(); _thread.Join(); _asyncBuffer = null; _thread = null; _isStopRequest = false; _isStopReceived = false; _isActive = false; } }