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


C# Engine.Stop方法代码示例

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


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

示例1: StopEngine

 public virtual void StopEngine(Engine engine)
 {
     try
     {
         engine.Stop();
         engine.Cooldown();
     }
     catch (InvalidOperationException e)
     {
         Console.WriteLine(e.Message + "engine number: " + Engines.IndexOf(engine));
         //throw new Exception("\nEngine if already off", e);
         throw;
     }
 }
开发者ID:IvanShvetsAMD,项目名称:InternshipStuff,代码行数:14,代码来源:PoweredAircraft.cs

示例2: Main

 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("Starting Cosmos CI Engine");
         var xEngine = new Engine();
         xEngine.HandleError = e => Console.WriteLine("Error occurred in engine: " + e.ToString());
         xEngine.Start();
         Console.WriteLine("Started. Press enter to exit");
         xEngine.Stop();
     }
     catch (Exception E)
     {
         Console.WriteLine("Error occurred: " + E.ToString());
     }
 }
开发者ID:gitter-badger,项目名称:CIEngine,代码行数:16,代码来源:Program.cs

示例3: worker

        private static void worker(object state)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
               
            PoolMsg msg = (PoolMsg)state;
            logger.InfoFormat("BEGIN: {0}({1})", methodName, msg.id.ToString());
        
			try	 
            {
                logger.InfoFormat("Worker{0} Start ...." , msg.id.ToString());
                Interlocked.Increment(ref workCount);
              
                using (Engine _instance = new Engine(true))
                {
                    _instance.Start();
                   
                    //Connect license Server
                    string serverIP = ConfigurationManager.AppSettings[LicenseServerAdress];
                    string serverPort = ConfigurationManager.AppSettings[LicenseServerPort];
                    string serverRetries = ConfigurationManager.AppSettings[LicenseServerRetries];
                    string serverTimeout = ConfigurationManager.AppSettings[LicenseServerTimeout];

                    if (!string.IsNullOrEmpty(serverIP) &&
                        !string.IsNullOrEmpty(serverPort))
                    {
                        _instance.LicenseServer.PreferredConnection.Address = serverIP;
                        _instance.LicenseServer.PreferredConnection.Port = int.Parse(serverPort);
                        if (!string.IsNullOrEmpty(serverRetries))
                        {
                            _instance.LicenseServer.PreferredConnection.Retries = int.Parse(serverRetries);
                        }

                        if (!string.IsNullOrEmpty(serverTimeout))
                        {
                            _instance.LicenseServer.PreferredConnection.Timeout = int.Parse(serverTimeout);
                        }

                       
                        if (_instance.LicenseServer.Connect())
                        {
                            logger.InfoFormat("Worker{0} Bartender connected to license server:{1} port:{2} succes! ", msg.id.ToString(), serverIP, serverPort);
                        }

                        else
                        {
                            string errorText = string.Format("Worker{0} Bartender connect to license server:{1} port:{2} fail! ", msg.id.ToString(), serverIP, serverPort);
                            throw new Exception(errorText);
                        }
                       
                    }
                    else
                    {
                        string errorText = string.Format("Worker{0} No setup license server address & Port! ", msg.id.ToString());
                        logger.Error(errorText);
                        //throw new Exception("No setup license server address & Port");
                    }
                    msg.WaitEvent.Set();
                                     
                    while (!_shouldStop &&
                            (queue.Count > 0 || 
                            workerEvent.WaitOne()))
                    {
                        PoolItem item = getItem();
                        if (item != null && 
                            !item.hasTimeout)
                        { 
                            try
                            {
                                logger.DebugFormat("Worker{0} is starting for producer thread Id :{1}  Source Btw File :{2}",msg.id.ToString(), item.ThreadId.ToString(), item.BtwSrcFileName);
                                BartenderUTL.GenBitmapFile(_instance, item);                                
                                logger.DebugFormat("Worker{0} has finished producer thread Id :{1}  Source Btw File :{2}", msg.id.ToString(), item.ThreadId.ToString(), item.BtwSrcFileName);
                            }
                            catch (Exception e1)
                            {
                                item.HasError = true;
                                item.ErrorText = e1.Message;
                                logger.Error(e1.Message, e1);                               
                            }
                            finally
                            {
                                item.producerEvent.Set();
                            }
                        }
                    }

                    //stop engine
                    _instance.Stop();
                    logger.InfoFormat("Worker{0} Stop" , msg.id.ToString());
                }
            }
            catch (Exception e)
            {
                msg.HasError = true;
                msg.ErrorText = "Worker" + msg.id.ToString() +" "  + e.Message;
                logger.Error(e.Message, e);
			    				
            }
			finally
			{
                Interlocked.Decrement(ref workCount);
//.........这里部分代码省略.........
开发者ID:wra222,项目名称:testgit,代码行数:101,代码来源:BartenderPool.cs


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