Пример #1
0
            /// <exception cref="InvalidOperationException">
            ///     The <see cref="INotificationContext.InvokeAsync"/> method of the <see cref="INotificationContext"/> object returns <c>null</c>.
            /// </exception>
            public void UpdateValues([NotNull] INotificationContext notificationContext, Lists listsWithItemsToBeRemoved)
            {
                var local = this;
                var threadAffineUpdates = notificationContext.InvokeAsync(
                    () =>
                {
                    foreach (var observableObjectInfo in local.ThreadAffine)
                    {
                        if (!observableObjectInfo.UpdateValues())
                        {
                            listsWithItemsToBeRemoved.ThreadAffine.Add(observableObjectInfo);
                        }
                    }
                });

                if (threadAffineUpdates == null)
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "The '{0}' method of the '{1}' class returns null.",
                                  nameof(INotificationContext.InvokeAsync),
                                  notificationContext.GetType().Name));
                }

                foreach (var observableObjectInfo in ThreadSafe)
                {
                    if (!observableObjectInfo.UpdateValues())
                    {
                        listsWithItemsToBeRemoved.ThreadSafe.Add(observableObjectInfo);
                    }
                }

                threadAffineUpdates.GetAwaiter().GetResult();
            }