/// <summary> /// Starts the producer thread. /// </summary> public void StartProducer() { if (Interlocked.CompareExchange(ref _started, 1, 0) == 1) { return; } _producerEndEvent.Reset(); Task.Run(async() => { try { var prodMethods = new ProducerMethods(this); await _producerFunc(prodMethods, _tokenSource.Token).ConfigureAwait(false); } catch (Exception ex) { Core.Log.Write(ex); } _producerEndEvent.Set(); }, _tokenSource.Token); }
/// <summary> /// Starts the producer thread. /// </summary> public void StartProducer() { if (_started) { return; } _started = true; _producerEndEvent.Reset(); Task.Run(async() => { try { var prodMethods = new ProducerMethods(this); await _producerFunc(prodMethods, _tokenSource.Token).ConfigureAwait(false); } catch (Exception ex) { Core.Log.Write(ex); } _producerEndEvent.Set(); }, _tokenSource.Token); }