예제 #1
0
파일: SimpleFxBase.cs 프로젝트: BgRva/Blob1
 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);
         }
     }
 }
예제 #2
0
파일: SimpleFxBase.cs 프로젝트: BgRva/Blob1
        /// <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;
            }
        }
예제 #3
0
 internal override void _myFx_ExecuteCompleted(ISimpleFx sender, FxCompletedEventArgs ea)
 {
     _myFx_ExecuteCompleted_TimesCalled++;
 }
예제 #4
0
        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();
        }
예제 #5
0
 public void ExecuteCompleted_DummyHandler(ISimpleFx sender, FxCompletedEventArgs ea)
 {
     ExecuteCompleted_TimesCalled++;
     RecievedEventArgs = ea;
     RecievedSender = sender;
 }
예제 #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);
         }
     }
 }