Пример #1
0
 public void proc(object sender, procEventArgs e)
 {
     lock (threadLock)
     {
         Console.WriteLine("Заявка с номером {0}", e.id);
         requestCount++;
         for (int i = 0; i < pool.Length; i++)
         {
             if (!pool[i].in_use)
             {
                 pool[i].wait++;
             }
         }
         for (int i = 0; i < pool.Length; i++)
         {
             if (!pool[i].in_use)
             {
                 pool[i].work++;
                 pool[i].in_use = true;
                 pool[i].thread = new Thread(new ParameterizedThreadStart(Answer));
                 pool[i].thread.Start(e.id);
                 processedCount++;
                 return;
             }
         }
         rejectedCount++;
     }
 }
Пример #2
0
        public void Work()
        {
            procEventArgs e = new procEventArgs();

            id++;
            e.id = id;
            this.OnProc(e);
        }
Пример #3
0
        protected virtual void OnProc(procEventArgs e)
        {
            EventHandler <procEventArgs> handler = request;

            if (handler != null)
            {
                handler(this, e);
            }
        }