Example #1
0
        /// <summary>
        /// Check if the task has been completed
        /// </summary>
        /// <param name="self">Class instance that contains the properties</param>
        /// <param name="completionSource">Completion source that was used to create the monitored task</param>
        /// <returns>True - Task completed, otherwise false</returns>
        private static bool TaskCompleted(this INotifyPropertyChanged self,
                                          out TaskCompletionSource <bool> completionSource)
        {
            var taskCompleted = true;
            var properties    = self.GetBlockingProperties();

            completionSource = CompletionSources.ContainsKey(self) ? CompletionSources[self] : null;
            foreach (var property in properties)
            {
                var attribute = property.GetCustomAttribute <BlockingPropertyAttribute>();
                if (!property.GetValue(self).Equals(attribute.ExpectedValue))
                {
                    taskCompleted = false;
                }
            }
            return(taskCompleted);
        }