Exemple #1
0
 internal virtual void OnExecuteCompleted(FxCompletedEventArgs ea)
 {
     if (ExecuteCompleted != null)
     {
         if (IsAsynch)
         {
             if (AsynchOp != null)
             {
                 AsynchOp.Post
                 (
                     delegate(object arg) { ExecuteCompleted(this, (FxCompletedEventArgs)arg); },
                     ea
                 );
             }
         }
         else
         {
             ExecuteCompleted(this, ea);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Sends out completion notifications.  !!!Important:  you must set the <see cref="Status"/> before calling
        /// this method.
        /// </summary>
        /// <param name="progressAtCompletion"></param>
        /// <param name="isCancelled"></param>
        /// <param name="ex"></param>
        /// <param name="mssg"></param>
        internal void ExecComplete(int progressAtCompletion, bool isCancelled, Exception ex, string mssg)
        {
            if (!CompletionCalled)
            {
                CompletionCalled = true;

                FxCompletedEventArgs arg = null;
                string logTitle = null;
                string logMssg = mssg;
                if (WorkerStatus == FxWorkerStatus.Error)
                {
                    if (ex != null)
                    {
                        logTitle = BlueSpider.Common.Constants.LogEntryTitle_Exception;
                        logMssg = ex.Message;
                        arg = new FxCompletedEventArgs(progressAtCompletion, mssg, ex, false);
                        OnExecuteCompleted(arg);
                    }
                    else
                    {
                        throw new InvalidOperationException(Properties.Resources.MssgFxExceptionIsNull);
                    }
                }
                else if (IsCancelled)
                {
                    logTitle = BlueSpider.Common.Constants.LogEntryTitle_Cancelled;
                    arg = new FxCompletedEventArgs(progressAtCompletion, mssg, ex, true);
                    OnExecuteCompleted(arg);
                }
                else if (WorkerStatus == FxWorkerStatus.Completed)
                {
                    logTitle = BlueSpider.Common.Constants.LogEntryTitle_End;
                    arg = new FxCompletedEventArgs(progressAtCompletion, mssg, ex, false);
                    OnExecuteCompleted(arg);
                }
                else if (WorkerStatus == FxWorkerStatus.Uninitialized)
                {
                    logTitle = BlueSpider.Common.Constants.LogEntryTitle_End;
                    arg = new FxCompletedEventArgs(progressAtCompletion, mssg, ex, false);
                    OnExecuteCompleted(arg);
                }
                else
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.MssgFxInvalidWorkerStatus, WorkerStatus));
                }

                #region Log
                _logger.Debug("ExecComplete() end");
                #endregion

                AsynchOp = null;
            }
        }
 internal override void _myFx_ExecuteCompleted(ISimpleFx sender, FxCompletedEventArgs ea)
 {
     _myFx_ExecuteCompleted_TimesCalled++;
 }
        public void ExecComplete_WhenWorkerStatusIsUninitialized()
        {
            Exception ex = null;
            string mssg = null;
            bool isCancelled = false;
            int progAtCompletion = 100;

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.ExpectAndReturn(_fx.CompletionCalled, false);
                _fx.CompletionCalled = true;
                recorder.ExpectAndReturn(_fx.WorkerStatus, FxWorkerStatus.Uninitialized).RepeatAlways();
                FxCompletedEventArgs ea = new FxCompletedEventArgs(progAtCompletion, mssg, ex, isCancelled);
                _fx.OnExecuteCompleted(ea);

                _fx.AsynchOp = null;
            }

            _fx.ExecComplete(progAtCompletion, isCancelled, ex, mssg);

            MockManager.Verify();
        }
Exemple #5
0
 public void ExecuteCompleted_DummyHandler(ISimpleFx sender, FxCompletedEventArgs ea)
 {
     ExecuteCompleted_TimesCalled++;
     RecievedEventArgs = ea;
     RecievedSender = sender;
 }
Exemple #6
0
 internal virtual void _myFx_ExecuteCompleted(ISimpleFx sender, FxCompletedEventArgs ea)
 {
     // !!! Important to always check for cancelled, then error, with EventArgs inheriting from AsyncCompletedEventArgs
     if (sender != null)
     {
         if (ea.Cancelled)
         {
             FxCompletedByCancel(ea.Message);
         }
         else if (ea.Error != null)
         {
             FxCompletedByError(ea.Error.Message);
         }
         else
         {
             FxCompleted(ea.Message);
         }
     }
 }