[ExcludeFromCodeCoverage] //excluded from code coverage since this class is a 1 liner that starts up a background thread public virtual void CreateAndStart(Action action) { SyncHelper.ExecuteSafely(sync, () => spanProcessorTaskInstance == null || spanProcessorTaskInstance.Status == TaskStatus.Faulted, () => { spanProcessorTaskInstance = Task.Factory.StartNew(() => ActionWrapper(action), cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }); }
public Task Start() { SyncHelper.ExecuteSafely(_syncObj, () => !IsStarted, () => { _spanProcessorTask.Start(LogSubmittedSpans); IsStarted = true; }); return(Task.CompletedTask); }
static SpanCollector GetInstance(Uri uri, uint maxProcessorBatchSize) { SyncHelper.ExecuteSafely(syncObj, () => instance == null, () => { instance = new SpanCollector(uri, maxProcessorBatchSize); }); return(instance); }
public void Start(Func <Task> asyncAction) { if (asyncAction != null) { SyncHelper.ExecuteSafely(_sync, () => _taskInstance == null || _taskInstance.Status == TaskStatus.Faulted, () => { _taskInstance = Task.Factory.StartNew(() => TaskExecuteLoop(asyncAction), _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }); } }
public virtual void Stop() { SyncHelper.ExecuteSafely(syncObj, () => IsStarted, () => { spanProcessor.Stop(); IsStarted = false; }); }
public void Stop() { SyncHelper.ExecuteSafely(_sync, () => _cancellationTokenSource.Token.CanBeCanceled, () => _cancellationTokenSource.Cancel()); }
public virtual void StopTask() { SyncHelper.ExecuteSafely(sync, () => cancellationTokenSource.Token.CanBeCanceled, () => cancellationTokenSource.Cancel()); }