Пример #1
0
        public async Task <TimeSpan> RunAsync(CancellationToken cancellationToken)
        {
            TraceSourceManager.SetTraceVerbosityForAll(TraceVerbosity.Fatal);

            await Wait(_options.Value.InitialDelay, cancellationToken, TimeSpan.FromHours(1));

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    await RunLoop(cancellationToken);
                }
                catch (OperationCanceledException e) when(e.CancellationToken == cancellationToken)
                {
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "AzureDevOpsTimelineLoop failed with unhandled exception");
                }

                await Wait(_options.Value.Interval, cancellationToken, TimeSpan.FromHours(6));
            }

            return(TimeSpan.Zero);
        }
Пример #2
0
        protected override Server CreateServer()
        {
            TCPServer server = new TCPServer(CONNECTION_REQUEST_PORT);

            server.Tracing = TraceSourceManager.GetInstance(_serverSourceName);
            //server.HandleMessage +=
            //server.HandleError +=
            return(server);
        }
Пример #3
0
        public ChetchService(String traceSourceName, String logName)
        {
            if (logName != null)
            {
                EVENT_LOG_NAME = logName;
                if (!AppConfig.VerifyEventLogSources(EVENT_LOG_NAME))
                {
                    throw new Exception("Newly created event log sources.  Restart required");
                }
            }

            if (traceSourceName != null)
            {
                Tracing = TraceSourceManager.GetInstance(traceSourceName);
                Tracing?.TraceEvent(TraceEventType.Information, 0, "Created service with trace source {0} and event log {1}", traceSourceName, logName);
            }

            try
            {
                CultureInfo defaultCultureInfo = System.Globalization.CultureInfo.DefaultThreadCurrentCulture;
                CultureInfo currentCultureInfo = Thread.CurrentThread.CurrentCulture;
                if (defaultCultureInfo == null && currentCultureInfo == null)
                {
                    throw new Exception("Both default and current CultureInfo are null!");
                }
                Tracing?.TraceEvent(TraceEventType.Information, 0, "Current CultureInfo {0}, Default CultureInfo {1}", currentCultureInfo.Name, defaultCultureInfo?.Name);
                if ((currentCultureInfo != null && !IsSupportedCulture(currentCultureInfo)) || (defaultCultureInfo != null && !IsSupportedCulture(defaultCultureInfo)))
                {
                    String cultureName = SUPPORTED_CULTURES.Split(',')[0];
                    Tracing?.TraceEvent(TraceEventType.Warning, 0, "CultureInfo is not supported so changing to {0}", cultureName);

                    CultureInfo supportedCultureInfo = new CultureInfo(cultureName);
                    Thread.CurrentThread.CurrentCulture = supportedCultureInfo;
                    System.Globalization.CultureInfo.DefaultThreadCurrentCulture = supportedCultureInfo;
                }
                Tracing?.TraceEvent(TraceEventType.Information, 0, "Current CultureInfo {0}, Default CultureInfo {1}", Thread.CurrentThread.CurrentCulture?.Name, System.Globalization.CultureInfo.DefaultThreadCurrentCulture?.Name);
            } catch (Exception e)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, e.Message);
                throw e;
            }
        }