Пример #1
0
        /// <summary>
        ///     Queries the message source.
        /// </summary>
        /// <param name="source">The message source to query.</param>
        /// <returns>Returns a task object.</returns>
        private async Task RequestMessagesAsync(IMessageSource source)
        {
            Application.Current.AssertBackgroundThread();

            await Application.Current.Dispatcher.InvokeAsync(() => _messages.Clear());

            var messages = await source.GetMessagesAsync();

            await Application.Current.Dispatcher.InvokeAsync(() => {
                _messages.DeferNotifications = true;
                _messages.AddRange(messages);
                _messages.DeferNotifications = false;
                _messages.NotifyCollectionChanged();
            });
        }