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++; } }
public void Work() { procEventArgs e = new procEventArgs(); id++; e.id = id; this.OnProc(e); }
protected virtual void OnProc(procEventArgs e) { EventHandler <procEventArgs> handler = request; if (handler != null) { handler(this, e); } }