System.ComponentModel.Async.Complete C# (CSharp) Метод

Complete() приватный Метод

private Complete ( object result, Exception error ) : void
result object
error Exception
Результат void
        private void Complete(object result, Exception error)
        {
            if (_completed) {
                throw new InvalidOperationException();
            }

            _result = result;
            _error = error;
            _completed = true;

            if (error == null) {
                RaisePropertyChanged("Result", "IsCompleted", "CanCancel");
            }
            else {
                RaisePropertyChanged("Error", "HasError", "IsCompleted", "CanCancel");
            }

            if (_completedHandler != null) {
                _completedHandler(this, EventArgs.Empty);
            }

            if ((error != null) && (_errorHandled == false)) {
                throw error;
            }
        }

Same methods

Async::Complete ( Exception error ) : void
Async::Complete ( object result ) : void

Usage Example

Пример #1
0
        public Async<Profile> GetProfile(string userName)
        {
            Async<Profile> asyncProfile = new Async<Profile>();

            _twitterService.GetProfile(userName, delegate(Profile profile) {
                if (profile == null) {
                    asyncProfile.Complete(new Exception("The profile for '" + userName + "' could not be loaded."));
                }
                else {
                    asyncProfile.Complete(profile);
                }
            });

            return asyncProfile;
        }
All Usage Examples Of System.ComponentModel.Async::Complete