本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}