private void Process(object o) { while (true) { CommandArgs args; using (new TryLock(_syncObject, Timeout)) { if (_commands.Count == 0) { _inProcess = false; _disposeEvent.Set(); return; } args = _commands.Dequeue(); } try { using (args) { var command = _queue._api.GetCommand(args.Unpacked.Package.Id); command.Run(args); } } catch (Exception e) { _queue.OnError(e); } } }
private void Process(object o) { while (true) { CommandContainer commandContainer; using (new TryLock(syncObject, Timeout)) { if (commands.Count == 0) { inProcess = false; disposeEvent.Set(); return; } commandContainer = commands.Dequeue(); } try { commandContainer.Run(); } catch (Exception e) { queue.OnError(e); } } }