当前位置: 首页>>代码示例>>C#>>正文


C# HostControl.RequestAdditionalTime方法代码示例

本文整理汇总了C#中HostControl.RequestAdditionalTime方法的典型用法代码示例。如果您正苦于以下问题:C# HostControl.RequestAdditionalTime方法的具体用法?C# HostControl.RequestAdditionalTime怎么用?C# HostControl.RequestAdditionalTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HostControl的用法示例。


在下文中一共展示了HostControl.RequestAdditionalTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public bool Start(HostControl hostControl)
        {
            _log.InfoFormat("Starting Subscriber Activity Service");

            var started = new List<ServiceControl>();

            try
            {
                _services = _serviceBootstrappers.Select(x => x.CreateService()).ToList();

                _log.InfoFormat("Starting {0} services", _services.Count());

                foreach (ServiceControl activityService in _services)
                {
                    hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));
                    StartService(hostControl, activityService);

                    started.Add(activityService);
                }

                return true;
            }
            catch (Exception ex)
            {
                _log.Error("Service failed to start", ex);

                Parallel.ForEach(started, service =>
                    {
                        hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));
                        StopService(hostControl, service);
                    });

                throw;
            }
        }
开发者ID:kinpro,项目名称:RapidTransit,代码行数:35,代码来源:TopshelfHostservice.cs

示例2: Start

        public bool Start(HostControl hostControl)
        {
            _log = HostLogger.Get<SampleService>();

            _log.Info("SampleService Starting...");

            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            Thread.Sleep(1000);

            ThreadPool.QueueUserWorkItem(x =>
                {
    //                Thread.Sleep(3000);

  //                  _log.Info("Requesting a restart!!!");

//                    hostControl.Restart();

//                _log.Info("Dying an ungraceful death");
//
//                throw new InvalidOperationException("Oh, what a world.");
                });
            _log.Info("SampleService Started");

            return true;
        }
开发者ID:CharlieBP,项目名称:Topshelf,代码行数:26,代码来源:SampleService.cs

示例3: Start

        public bool Start(HostControl hostControl)
        {
            _log.InfoFormat($"Starting {GetType().GetDisplayName()}");

            var started = new List<ServiceControl>();

            try
            {
                var scanner = new ServiceAssemblyScanner();

                List<AssemblyRegistration> registrations = scanner.GetAssemblyRegistrations().ToList();

                _log.Info($"Found {registrations.Count} assembly registrations");
                foreach (var registration in registrations)
                {
                    _log.Info($"Assembly: {registration.Assembly.GetName().Name}");
                    foreach (var type in registration.Types)
                        _log.Info($"  Type: {type.GetTypeName()}");
                }

                var busFactoryType = scanner.GetHostBusFactoryType();
                if (busFactoryType == null)
                    throw new ConfigurationException("A valid transport assembly was not found.");

                _bootstrapperScope = CreateBootstrapperScope(registrations, busFactoryType);

                var bootstrappers = _bootstrapperScope.Resolve<IEnumerable<IServiceBootstrapper>>();

                List<ServiceControl> services = bootstrappers.Select(x => x.CreateService()).ToList();

                Parallel.ForEach(services, serviceControl =>
                {
                    hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));

                    StartService(hostControl, serviceControl);

                    lock (started)
                    {
                        started.Add(serviceControl);
                    }
                });

                _services.AddRange(started);

                return true;
            }
            catch (Exception ex)
            {
                _log.Error("Service failed to start", ex);

                Parallel.ForEach(started, service =>
                {
                    hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));
                    StopService(hostControl, service);
                });

                throw;
            }
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:59,代码来源:MassTransitHostService.cs

示例4: Stop

        public bool Stop(HostControl hostControl)
        {
            _log.InfoFormat("Stopping {0} services", _services.Count());

            if (_services != null)
            {
                Parallel.ForEach(_services, service =>
                    {
                        hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));
                        StopService(hostControl, service);
                    });
            }

            return true;
        }
开发者ID:kinpro,项目名称:RapidTransit,代码行数:15,代码来源:TopshelfHostservice.cs

示例5: Start

        /// <summary>
        /// Creates an instance of the TabMonAgent and starts it.
        /// </summary>
        /// <param name="hostControl">Service HostControl object</param>
        /// <returns>Indicator that service succesfully started</returns>
        public bool Start(HostControl hostControl)
        {
            // Request additional time from the service host due to how much initialization has to take place.
            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            // Initialize and start service.
            try
            {
                agent = new TabMonAgent();
            }
            catch (Exception)
            {
                return false;
            }
            agent.Start();
            return agent.IsRunning();
        }
开发者ID:yaswanth369,项目名称:TabMon,代码行数:22,代码来源:Bootstrapper.cs

示例6: Start

        public bool Start(HostControl hostControl)
        {
            _log.Info("SampleService Starting...");

            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            Thread.Sleep(1000);

            ThreadPool.QueueUserWorkItem(x =>
                {
                    Thread.Sleep(3000);

                    _log.Info("Requesting stop");

                    hostControl.Stop();
                });
            _log.Info("SampleService Started");

            return true;
        }
开发者ID:henningc,项目名称:Topshelf,代码行数:20,代码来源:SampleService.cs

示例7: Stop

        /// <summary>
        /// Stops the specified host control.
        /// </summary>
        /// <param name="hostControl">The host control.</param>
        /// <returns></returns>
        public override bool Stop(HostControl hostControl)
        {
            try
            {
                Logger.Information("Stopping Event Processor");
                hostControl.RequestAdditionalTime(TimeSpan.FromMinutes(1));
                _processorHost.UnregisterEventProcessorAsync().Wait(TimeSpan.FromMinutes(1));
            }
            catch (Exception ex)
            {
                Logger.Warning(ex, "Error unregistering Event Processor");
            }

            return base.Stop(hostControl);
        }
开发者ID:bradsjm,项目名称:AprsEventHubDemo,代码行数:20,代码来源:EventProcessorService.cs

示例8: Start

        public bool Start(HostControl hostControl)
        {
            _log.Info("SampleService Starting...");

            hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(10));

            _server.OpenAsync();
            var setting = JsonOperater.GetAppSetting();
            _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            _timer.Interval = 1000 * 60 * setting.Period;
            _timer.Enabled = true;
            _timer.Start();
            //var setting = JsonOperater.GetAppSetting();
            //FileManager.InitStates(setting);

            //foreach (var key in setting.Directory.Keys)
            //{
            //    if (FileShare.ConnectState(setting.Directory[key], setting.UserName, setting.PassWord))
            //    {
            //        var needAnalyzes = FileManager.GetNeedAnalyzeFiles(setting.Directory[key], key);
            //        Analyzer.AnalyzeRecord(needAnalyzes, setting, key);
            //    }
            //}
            _log.Info("SampleService Started");

            return true;
        }
开发者ID:RainBowChina,项目名称:IISLogAnalyzer,代码行数:27,代码来源:SampleService.cs


注:本文中的HostControl.RequestAdditionalTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。