Esempio n. 1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 internal BackgroundTaskTerminatedEventArgs(object userState, BackgroundTaskTerminatedReason reason, object[] results, Exception ex)
 {
     _userState = userState;
     _reason    = reason;
     _results   = results;
     _exception = ex;
 }
Esempio n. 2
0
        private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // if there was an unhandled exception in the worker thread, then e.Error will be non-null
            // if there was a handled exception in the worker thread, and the worker passed it back, _error will be non-null
            // therefore, coalesce the results, giving precedence to the unhandled exception
            _error = e.Error ?? _error;

            // determine the reason
            BackgroundTaskTerminatedReason reason = (_error != null) ? BackgroundTaskTerminatedReason.Exception
                : (e.Cancelled ? BackgroundTaskTerminatedReason.Cancelled : BackgroundTaskTerminatedReason.Completed);

            // the e.Result object is an exception for e.Cancelled status, we don't want that
            object[] results = (e.Cancelled ? null : (object[])e.Result);

            EventsHelper.Fire(_terminated, this,
                              new BackgroundTaskTerminatedEventArgs(_userState, reason, results, _error));
        }
Esempio n. 3
0
		/// <summary>
		/// Constructor.
		/// </summary>
        internal BackgroundTaskTerminatedEventArgs(object userState, BackgroundTaskTerminatedReason reason, object[] results, Exception ex)
        {
            _userState = userState;
            _reason = reason;
            _results = results;
            _exception = ex;
        }