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


C# Service.Stop方法代码示例

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


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

示例1: StartServer

 public void StartServer()
 {
     var hosting = new Service(9090);
     hosting.Start();
     for (int i = 0; i < 10; i++)
     {
         Thread.Sleep(200);
     }
     hosting.Stop();
 }
开发者ID:perryofpeek,项目名称:svcexample,代码行数:10,代码来源:TestServer.cs

示例2: Main

        private static void Main(string[] args)
        {
            SetupConsole();
            try
            {
                var config = new FilterConfig("Config\\Filter.xml");

                //Logger
                foreach (var logger in config.Logger)
                {
                    StaticLogger.Create(logger.Key);
                    StaticLogger.SetLogLevel(logger.Value.Ordinal, logger.Key);
                }
                StaticLogger.SetInstance();

                //StaticLogger.Instance.Trace("Trace");
                //StaticLogger.Instance.Debug("Debug");
                //StaticLogger.Instance.Info("Info");
                //StaticLogger.Instance.Warn("Warn");
                //StaticLogger.Instance.Error("Error");
                //StaticLogger.Instance.Fatal("Fatal");

                //Services
                _serviceCollection = new ServiceCollection();
                foreach (var serviceSettings in config.Services)
                {
                    var service = new Service(serviceSettings.Value);
                    _serviceCollection.Add(service);
                }

                //Plugins
                var pluginManager = new PluginManager(config.Plugins);
                foreach (var service in _serviceCollection)
                {
                    pluginManager.RegisterService(service);
                }
                var pluginCount = pluginManager.Load();
                StaticLogger.Instance.Info($"{pluginCount} plugins registered.");

                //Start services
                foreach (var service in _serviceCollection)
                {
                    var result = service.Start();
                    if (result == false)
                        StaticLogger.Instance.Fatal($"Failed to start {service.Settings.Name}, check Filter.xml and prev. errors");
                }

                StaticLogger.Instance.Info("Successfully initilized.");
                Console.Beep();

                while (true)
                {
                    var line = Console.ReadLine();
                    if (line == "exit" || line == "quit")
                        break;
                }
                foreach (var service in _serviceCollection)
                {
                    service.Stop();
                }
            }
            catch (Exception ex)
            {
                Console.Beep();
                Console.WriteLine("Something fucked up really hard, please check Filter.xml");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.Beep();
                Console.ReadLine();
            }
        }
开发者ID:GoneUp,项目名称:ModuleFilter,代码行数:71,代码来源:Program.cs

示例3: _StartStopTest

    private void _StartStopTest()
    {
        Console.WriteLine("Start/Stop service test:");

        using (Service svc = new Service("StartStopTest"))
        {
            svc.Start();
            Console.WriteLine("Start service, wait 2 seconds...");
            Thread.Sleep(2000);

            Console.WriteLine("Stop service...");
            svc.Stop();

            Console.WriteLine("ReStart service...");
            svc.Start(2);
            Thread.Sleep(5000);

            Console.WriteLine("Stop service...");
            svc.Stop();
        }

        Console.WriteLine("Press any key to finish Start/Stop service test...");
        Console.ReadKey();
    }
开发者ID:lailongwei,项目名称:llbc,代码行数:24,代码来源:TestCase_Comm_Service.cs


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