internal void EndDispatch(SwDocument doc) { lock (m_Lock) { m_DocsDispatchQueue.Remove(doc); var index = m_ModelsDispatchQueue.FindIndex(d => m_Comparer.Equals(d, doc.Model)); if (index != -1) { m_ModelsDispatchQueue.RemoveAt(index); } if (doc is SwUnknownDocument) { doc = (SwDocument)(doc as SwUnknownDocument).GetSpecific(); } Dispatched?.Invoke(doc); if (!m_DocsDispatchQueue.Any()) { DispatchAllModels(); } } }
private void DispatchAllModels() { lock (m_Lock) { foreach (var model in m_ModelsDispatchQueue) { SwDocument doc; switch (model) { case IPartDoc part: doc = new SwPart(part, m_App, m_Logger, true); break; case IAssemblyDoc assm: doc = new SwAssembly(assm, m_App, m_Logger, true); break; case IDrawingDoc drw: doc = new SwDrawing(drw, m_App, m_Logger, true); break; default: throw new NotSupportedException(); } Dispatched?.Invoke(doc); } m_ModelsDispatchQueue.Clear(); } }
private async Task Dispatch(CommandBase command) { Dispatched?.Invoke(this, new CommandRunnerEvent(command)); if (command.RunOnUiThread) { await _executeUiThreadFunc(async() => await ExecuteOne(command).ConfigureAwait(false)).ConfigureAwait(false); } else { await Task.Run(() => ExecuteOne(command)).ConfigureAwait(false); } }
private void NotifyDispatchedSafe(SwDocument doc) { try { m_Logger.Log($"Dispatched '{doc.Title}'", LoggerMessageSeverity_e.Debug); Dispatched?.Invoke(doc); } catch (Exception ex) { m_Logger.Log($"Unhandled exception while dispatching the document '{doc.Title}'", LoggerMessageSeverity_e.Error); m_Logger.Log(ex); } }
private void NotifyDispatchedSafe(SwDocument doc) { try { m_Logger.Log($"Dispatched '{doc.Title}'"); Dispatched?.Invoke(doc); } catch (Exception ex) { m_Logger.Log($"Unhandled exception while dispatching the document '{doc.Title}'"); m_Logger.Log(ex); } }
void ICommandPatternObserver.OnCommandDispatched(ICommandDispatch dispatch) => Dispatched?.Invoke((ICommandDispatch <TSpec>)dispatch);
void ICommandPatternObserver <TSpec> .OnCommandDispatched(ICommandDispatch <TSpec> dispatch) => Dispatched?.Invoke(dispatch);