private void threadItemExecute(object state) { while (!_isStop) { IThreadQueueExecuteItem item = null; if (_queue.TryDequeue(out item) && !_isStop) { try { item.Execute(item.State); } catch (Exception) { } Thread.Sleep(100); } else { Thread.Yield(); Thread.Sleep(200); } } }
public void Execute(IThreadQueueExecuteItem executeItem) { if (_isClosed) { return; } _queue.Enqueue(executeItem); }
public void Execute(IThreadQueueExecuteItem executeItem) { if (_isClosed) { return; } lock (lockerObj) { workQueue.Enqueue(executeItem); au.Set(); } }
public void Clear() { try { if (!_queue.IsEmpty) { IThreadQueueExecuteItem item = null; while (!_queue.IsEmpty) { _queue.TryDequeue(out item); } } } catch (Exception) { } }
private void run(object state) { IThreadQueueExecuteItem processItem = null; while (true) { lock (workQueue) { if (workQueue.Count <= 0) { processItem = null; } else { processItem = workQueue.Dequeue(); } } if (processItem == null) { au.WaitOne(500); } else { try { processItem.Execute(state); } catch { } Thread.Yield(); Thread.Sleep(100); } } }