예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
 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);
     }
 }
예제 #6
0
 void ICommandPatternObserver.OnCommandDispatched(ICommandDispatch dispatch)
 => Dispatched?.Invoke((ICommandDispatch <TSpec>)dispatch);
예제 #7
0
 void ICommandPatternObserver <TSpec> .OnCommandDispatched(ICommandDispatch <TSpec> dispatch)
 => Dispatched?.Invoke(dispatch);