Example #1
0
        internal void Add(Window window)
        {
            // this method and the Closed event are both run on the main thread
            // this means manipulation of the list is safe without locks
            window.Closed += (s, e) =>
            {
                if (windows.Remove(window) && windows.Count == 0)
                {
                    AllWindowsClosed?.Invoke(this, EventArgs.Empty);
                }
            };

            windows.Add(window);
        }
 /// <summary>
 /// Raises <see cref="AllWindowsClosed"/> event.
 /// </summary>
 private static Task RaiseAllWindowsClosed()
 {
     return(InvokeOnDispatcherAsync(() => AllWindowsClosed?.Invoke(null, EventArgs.Empty)));
 }