本文整理汇总了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;
}
}
示例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());
}
}
示例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);
//.........这里部分代码省略.........