[Bartender]TaskEngines.GetEnumerator Method

TaskEngines.GetEnumerator Method

Gets the enumerator used to iterate through the collection.
Namespace: Seagull.BarTender.PrintServer
Assembly: Seagull.BarTender.Print (in Seagull.BarTender.Print.dll) Version: 2016 R1

public IEnumerator GetEnumerator()
Return Value
Type: IEnumerator
Implements
IEnumerable.GetEnumerator()
Examples
The following example demonstrates how to use the GetEnumerator interface of TaskEngines to visit each TaskEngine held within a TaskManager.

public void Demo()
{
   // Initialize a new TaskManager object.
   using (TaskManager btTaskManager = new TaskManager())
   {
      // Start a few task engines.
      btTaskManager.Start(3);

      // Create some printing tasks to be distributed between the engines.
      PrintLabelFormatTask[] tasks = new PrintLabelFormatTask[4];
      tasks[0] = new PrintLabelFormatTask(@"C:\Format1.btw");
      tasks[1] = new PrintLabelFormatTask(@"C:\Format2.btw");
      tasks[2] = new PrintLabelFormatTask(@"C:\Format3.btw");
      tasks[3] = new PrintLabelFormatTask(@"C:\Format4.btw");

      // Enqueue the tasks.
      foreach (PrintLabelFormatTask t in tasks)
         btTaskManager.TaskQueue.QueueTask(t);

      // Stop the task engines as they finish up.
      while (btTaskManager.TaskEngines.BusyCount > 0)
      {
         // For each engine that is running, but not busy, terminate it
         // (foreach implicitly uses GetEnumerator).
         foreach (TaskEngine e in btTaskManager.TaskEngines)
            if (e.IsAlive && e.Status != TaskEngineStatus.Busy)
               e.Terminate();
         System.Threading.Thread.Sleep(1000);
      }

      // Make sure that all engines are stopped.
      if (btTaskManager.TaskEngines.AliveCount > 0)
         btTaskManager.Stop(10000, true);
   }
}
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie
应支付0元
点击重新获取
扫码支付

支付成功即可阅读