Esempio n. 1
0
        /// <summary>
        /// Stop tracing, records will be ignored.
        /// </summary>
        /// <returns></returns>
        public static bool Stop()
        {
            if (Interlocked.CompareExchange(ref _status, (int)Status.Stopped, (int)Status.Started) ==
                (int)Status.Started)
            {
                _dispatcher.Stop();
                _dispatcher = new VoidDispatcher();
                Logger.LogInformation("Tracing dispatcher stopped");
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Start tracing, records will be forwarded to the registered tracers, using the provided dispatcher.
        /// </summary>
        /// <returns>True if successfully started, false if error or the service was already running.</returns>
        public static bool Start(ILogger logger, IRecordDispatcher dispatcher)
        {
            if (Interlocked.CompareExchange(ref _status, (int)Status.Started, (int)Status.Stopped) ==
                (int)Status.Stopped)
            {
                Logger      = logger;
                _dispatcher = dispatcher;
                Logger.LogInformation("Tracing dispatcher started");
                Logger.LogInformation("HighResolutionDateTime is " + (HighResolutionDateTime.IsAvailable ? "available" : "not available"));
                return(true);
            }

            return(false);
        }