Example #1
0
 [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);
     });
 }
Example #2
0
 public Task Start()
 {
     SyncHelper.ExecuteSafely(_syncObj, () => !IsStarted, () =>
     {
         _spanProcessorTask.Start(LogSubmittedSpans);
         IsStarted = true;
     });
     return(Task.CompletedTask);
 }
Example #3
0
        static SpanCollector GetInstance(Uri uri, uint maxProcessorBatchSize)
        {
            SyncHelper.ExecuteSafely(syncObj, () => instance == null,
                                     () =>
            {
                instance = new SpanCollector(uri, maxProcessorBatchSize);
            });

            return(instance);
        }
Example #4
0
 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);
         });
     }
 }
Example #5
0
 public virtual void Stop()
 {
     SyncHelper.ExecuteSafely(syncObj, () => IsStarted, () => { spanProcessor.Stop(); IsStarted = false; });
 }
Example #6
0
 public void Stop()
 {
     SyncHelper.ExecuteSafely(_sync, () => _cancellationTokenSource.Token.CanBeCanceled,
                              () => _cancellationTokenSource.Cancel());
 }
Example #7
0
 public virtual void StopTask()
 {
     SyncHelper.ExecuteSafely(sync, () => cancellationTokenSource.Token.CanBeCanceled, () => cancellationTokenSource.Cancel());
 }