Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- ILog Log = new FileLog();
- try
- {
- HostFactory.Run(serviceConfig =>
- {
- serviceConfig.Service<ServiceManager>(serviceInstance =>
- {
- serviceInstance.ConstructUsing(() => new ServiceManager());
- serviceInstance.WhenStarted(execute => execute.Start());
- serviceInstance.WhenStopped(execute => execute.Stop());
- });
- });
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex);
- Log.Error("Program.Main", ex, LogType.Error);
- Console.ReadLine();
- };
- }
- }
- class ServiceManager
- {
- xxx.....
- public bool Stop()
- {
- try
- {
- _log.Info("The service is stopping", LogType.Info);
- _service.StopExecuteProduceMessage();
- Task.WaitAll(_tasks.ToArray());
- _log.Info("The service is stopped", LogType.Info);
- }
- catch (Exception ex)
- {
- _log.Error("Stop", ex, LogType.Error);
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment