Exemple #1
0
        private static async Task <T> ShowAsync <T>(Func <Task <T> > show, IDispatcherWrapper dispatcher)
        {
            lock (DialogState)
            {
                while (DialogState.Showing)
                {
                    Monitor.Wait(DialogState);
                }
                DialogState.Showing = true;
            }

            // this next line creates a dependecy on the WindowService
            dispatcher = dispatcher ?? WindowWrapperHelper.Current().Dispatcher;

            dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));

            var result = await dispatcher.DispatchAsync(async() => await show());

            lock (DialogState)
            {
                DialogState.Showing = false;
                Monitor.PulseAll(DialogState);
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Fires a notification that the collection has been reset and should be queried for the changes.
        /// </summary>
        /// <param name="notify">The dispatcher wrapper to used for thread access.</param>
        public async void Reset(IDispatcherWrapper notify = null)
        {
            if (_suppressNotification > 0)
            {
                return;
            }

            if (notify == null)
            {
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                return;
            }

            await notify.DispatchAsync(() =>
            {
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            });
        }
Exemple #3
0
        private static async Task <T> ShowAsync <T>(Func <Task <T> > show, IDispatcherWrapper dispatcher)
        {
            lock (DialogState)
            {
                while (DialogState.Showing)
                {
                    Monitor.Wait(DialogState);
                }
                DialogState.Showing = true;
            }
            dispatcher = dispatcher ?? Locator.WindowWrapper.Current().Dispatcher;
            var result = await dispatcher.DispatchAsync(async() => await show());

            lock (DialogState)
            {
                DialogState.Showing = false;
                Monitor.PulseAll(DialogState);
            }
            return(result);
        }
Exemple #4
0
        private static async Task <T> ShowAsync <T>(Func <Task <T> > show, IDispatcherWrapper dispatcher)
        {
            lock (DialogState)
            {
                while (DialogState.Showing)
                {
                    Monitor.Wait(DialogState);
                }
                DialogState.Showing = true;
            }
            dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
            var result = await dispatcher.DispatchAsync(async() => await show());

            lock (DialogState)
            {
                DialogState.Showing = false;
                Monitor.PulseAll(DialogState);
            }
            return(result);
        }