Ejemplo n.º 1
0
 private void DoThreadWork(object param)
 {
     while (true)
     {
         if (_blockingQueue.Count == 0)
         {
             break;
         }
         TaskDelegateParam someParam = new TaskDelegateParam();
         someParam.tasksCount = _blockingQueue.Count;
         var task = _blockingQueue.Take();
         try
         {
             task(someParam);
         }
         catch (ThreadAbortException)
         {
             Thread.ResetAbort();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
     Console.WriteLine("Finished Thread #" + Thread.CurrentThread.ManagedThreadId);
 }
Ejemplo n.º 2
0
 private static void TestTask(TaskDelegateParam obj)
 {
     Thread.Sleep(1000);
     Console.WriteLine("completed task of " + obj.tasksCount);
 }