public async Task <bool> Close(bool force = false) { using (await asyncCriticalSection.EnterAsync()) { if (closed) { return(true); } bool wasActive = documentManager.ActiveDocument == this; // Raise the closing event. Handlers have a chance to cancel the save operation var args = new DocumentCloseEventArgs(this, force, wasActive); args.Cancel = false; await OnClosing(args); if (!force && args.Cancel) { return(false); } // Show the File not Saved UI if (!await ShowSaveUI(force)) { return(false); } closed = true; ClearTasks(); Closed?.SafeInvoke(this, args); // Reset the root view before closing the view, otherwise shell.CloseView will destroy it. // We need the view to be functional until after the window is closed. The Dispose() method // already takes care of disposing the view, which will destroy the widget it contains window.SetRootView(null); shell.CloseView(window, true); Counters.OpenDocuments--; Dispose(); return(true); } }
/// <summary> /// Open channel. /// </summary> public void Open() { _messageQueue.Open(); ThreadingHelper .Thread(() => CultureInfo.InvariantCulture.DoInCulture(() => { while (!_messageQueue.IsClosed) { try { KeyValuePair <DateTimeOffset, Message> pair; if (!_messageQueue.TryDequeue(out pair)) { break; } //if (!(message is TimeMessage) && message.GetType().Name != "BasketMessage") // Console.WriteLine("<< ({0}) {1}", System.Threading.Thread.CurrentThread.Name, message); _msgStat.Remove(pair.Value); NewOutMessage.SafeInvoke(pair.Value); } catch (Exception ex) { _errorHandler(ex); } } Closed.SafeInvoke(); })) .Name("{0} channel thread.".Put(Name)) //.Culture(CultureInfo.InvariantCulture) .Launch(); }