예제 #1
0
파일: Program.cs 프로젝트: valeryV99/Task1
 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);
 }
예제 #2
0
파일: Program.cs 프로젝트: valeryV99/Task1
 private static void TestTask(TaskDelegateParam obj)
 {
     Thread.Sleep(1000);
     Console.WriteLine("completed task of " + obj.tasksCount);
 }