コード例 #1
0
        private void DoProcess(object state)
        {
            Thread.Sleep(5000);
            BatchCleaningAsyncResult result = (BatchCleaningAsyncResult)state;

            OnCompleted(result);

            //try
            //{
            //    IProcess process = ProcessObjectLocator.LocateProcess(result.Batch.CleanupJobName);
            //    if (process != null)
            //    {
            //        process.DoProcess(result.Batch, null, null);
            //    }

            //}
            //catch (Exception ex)
            //{
            //    result.Exception = ex;
            //}
            //finally
            //{
            //    OnCompleted(result);
            //}
        }
コード例 #2
0
        protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
        {
            BatchCleaningAsyncResult processResult = result as BatchCleaningAsyncResult;

            if (processResult == null)
            {
                return;
            }
            processResult.Dispose();

            if (processResult.Exception != null && !context.IsCancellationRequested)
            {
                throw new ApplicationException("Error generating reports. See inner for details", processResult.Exception);
            }
        }
コード例 #3
0
        protected override void Cancel(AsyncCodeActivityContext context)
        {
            BatchCleaningAsyncResult result =
                context.UserState as BatchCleaningAsyncResult;

            context.MarkCanceled();

            if (result != null)
            {
                result.Canceled = true;
                if (result.RunningThread.IsAlive)
                {
                    result.RunningThread.Abort();
                }
            }
            base.Cancel(context);
        }
コード例 #4
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            Thread thread = new Thread(DoProcess)
            {
                IsBackground = true
            };
            BatchCleaningAsyncResult result = new BatchCleaningAsyncResult(callback, state)
            {
                Batch = Target.Get(context),

                RunningThread = thread,
            };

            context.UserState = result;

            thread.Start(result);
            return(result);
        }