当前位置: 首页>>代码示例>>C#>>正文


C# AsyncOperation.PostOperationCompleted方法代码示例

本文整理汇总了C#中System.ComponentModel.AsyncOperation.PostOperationCompleted方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncOperation.PostOperationCompleted方法的具体用法?C# AsyncOperation.PostOperationCompleted怎么用?C# AsyncOperation.PostOperationCompleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.AsyncOperation的用法示例。


在下文中一共展示了AsyncOperation.PostOperationCompleted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompletionMethod

        private void CompletionMethod(string output, Exception ex, bool cancelled, AsyncOperation asyncOp)
        {
            lock (userStateDictionary)
            {
                userStateDictionary.Remove(asyncOp.UserSuppliedState);
            }

            // results of the operation
            asyncOp.PostOperationCompleted(onCompletedDelegate,
                new LongTaskCompletedEventArgs(output, ex, cancelled, asyncOp.UserSuppliedState));
        }
开发者ID:ChegnduJackli,项目名称:Projects,代码行数:11,代码来源:AsyncComponent.cs

示例2: DispatchCompleting

 private void DispatchCompleting(MessageData responsemsg, Exception ex, bool canceled, AsyncOperation asyncOper)
 {
     if (!canceled)
     {
         lock (_userStateToLifetime.SyncRoot)
         {
             _userStateToLifetime.Remove(asyncOper.UserSuppliedState);
         }
     }
     TransmitCompletedEventArgs eventArgs = new TransmitCompletedEventArgs(responsemsg, ex, canceled, asyncOper.UserSuppliedState);
     asyncOper.PostOperationCompleted(onCompletedDelegate, eventArgs);
 }
开发者ID:joeiren,项目名称:quant.AidSystem,代码行数:12,代码来源:MsgDispatchEAP.cs

示例3: WorkerThreadStart

        private void WorkerThreadStart(AsyncOperation asyncOp, object userState, object argument)
        {
            Exception error = null;
            bool cancelled = false;
            DoWorkEventArgs e = new DoWorkEventArgs(userState, argument);

            try
            {
                this.OnDoWork(e);
                if (e.Cancel) cancelled = true;
            }
            catch (Exception ex)
            {
                error = ex;
            }

            lock (userStateToLifetime.SyncRoot)
            {
                userStateToLifetime.Remove(asyncOp.UserSuppliedState);
            }

            WorkerCompletedEventArgs arg = new WorkerCompletedEventArgs(error, cancelled, asyncOp.UserSuppliedState, argument);
            asyncOp.PostOperationCompleted(this.SendOrPostWorkerCompleted, arg);
        }
开发者ID:xianrendzw,项目名称:LightFramework.Net,代码行数:24,代码来源:AsyncEventWorker.cs

示例4: PrepareToRaiseCompletedEvent

        internal void PrepareToRaiseCompletedEvent(AsyncOperation asyncOP, ResolveCompletedEventArgs args)
        {
            asyncOP.PostOperationCompleted(OnResolveCompletedDelegate, args);
            lock (m_PeerNameResolverHelperListLock)
            {
                PeerNameResolverHelper helper = m_PeerNameResolverHelperList[args.UserState];
                if (helper == null)
                {
                    Logging.P2PTraceSource.TraceEvent(TraceEventType.Critical, 0, "userState for which we are about to call Completed event does not exist in the pending async list");
                }
                else
                {
                    Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, helper.TraceEventId, 
                        "userState {0} is being removed from the pending async list", args.UserState.GetHashCode());
                    m_PeerNameResolverHelperList.Remove(args.UserState);
                }

            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:19,代码来源:PeerNameResolver.cs

示例5: JobActionWorker

        private void JobActionWorker(AsyncOperation asyncOp, ActionType action, string reason, string label, bool suppressError)
        {
            Exception exception = null;

#pragma warning disable 56500
            try
            {
                switch (action)
                {
                    case ActionType.Start:
                        DoStartJobLogic(null);
                        break;

                    case ActionType.Stop:
                        DoStopJob();
                        break;

                    case ActionType.Suspend:
                        DoSuspendJob();
                        break;

                    case ActionType.Resume:
                        DoResumeJob(label);
                        break;

                    case ActionType.Abort:
                        DoAbortJob(reason);
                        break;

                    case ActionType.Terminate:
                        DoTerminateJob(reason, suppressError);
                        break;
                }
            }
            catch (Exception e)
            {
                // Called on a background thread, need to include any exception in
                // event arguments.
                exception = e;
            }
#pragma warning restore 56500

            var eventArgs = new AsyncCompletedEventArgs(exception, false, asyncOp.UserSuppliedState);

            var container = new AsyncCompleteContainer { EventArgs = eventArgs, Action = action };

            // End the task. The asyncOp object is responsible 
            // for marshaling the call.
            asyncOp.PostOperationCompleted(JobActionAsyncCompleted, container);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:50,代码来源:WorkflowJob2.cs

示例6: CompletionMethod

        // This is the method that the underlying, free-threaded 
        // asynchronous behavior will invoke.  This will happen on
        // an arbitrary thread.
        private void CompletionMethod(
            List<ProxyInfo> proxylistOk,
            Exception exception,
            bool canceled,
            AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (userStateToLifetime.SyncRoot)
                {
                    userStateToLifetime.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Package the results of the operation in a 
            // CalculatePrimeCompletedEventArgs.
            CompletedEventArgs e =
                new CompletedEventArgs(
                proxylistOk,
                exception,
                canceled,
                asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible 
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onCompletedDelegate, e);

            // Note that after the call to OperationCompleted, 
            // asyncOp is no longer usable, and any attempt to use it
            // will cause an exception to be thrown.
        }
开发者ID:Vinna,项目名称:DeepInSummer,代码行数:36,代码来源:ProxyValidater.cs

示例7: Generate


//.........这里部分代码省略.........
             report2.Dispose();
         }
         report = new NoticeReport(renderedNotices);
         this.m_GeneratedReport = report;
     }
     if ((this.m_ThreadExceptions.Count > 0) || this.m_IsCancelled)
     {
         ex = null;
         this.m_ThreadExceptions.TryDequeue(out ex);
         this.AbortOperation(asyncOp, ex, (System.TimeSpan) (System.DateTime.Now - now));
     }
     else
     {
         if ((this.m_NoticeCache.get_Count() > 0) && (this.m_Exporter != null))
         {
             logger.Info("Экспорт по домам управляющих компаний");
             int num9 = (int) ((this.m_Exporter.MaxPageCount * this.m_Template.AccountsInTemplate) / this.m_Template.PageCount);
             CachedNoticeInfoComparer comparer = new CachedNoticeInfoComparer();
             try
             {
                 foreach (string str in this.m_NoticeCache.Keys)
                 {
                     this.m_NoticeCache[str].Sort(comparer);
                     logger.Info("Экспорт домов УК " + str);
                     for (int n = 0; n < this.m_NoticeCache[str].get_Count(); n = (int) (n + num9))
                     {
                         System.Text.StringBuilder builder = new System.Text.StringBuilder();
                         int num11 = this.m_NoticeCache[str].get_Count();
                         if (num11 != 0)
                         {
                             int maxPageCount = this.m_Exporter.MaxPageCount;
                             int num13 = (int) (num11 - (n + maxPageCount));
                             num13 = (num13 < 1) ? ((int) 0) : num13;
                             using (StiReport report3 = new StiReport())
                             {
                                 report3.IsRendered = true;
                                 report3.NeedsCompiling = false;
                                 report3.RenderedPages.Clear();
                                 System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(System.IO.Path.Combine(this.m_Exporter.DestinationPath, str));
                                 if (!info.get_Exists())
                                 {
                                     info.Create();
                                 }
                                 string file = System.IO.Path.Combine(info.get_FullName(), string.Format("{0}_{1}.pdf", str, n / num9));
                                 for (int num14 = n; num14 < (num11 - num13); num14 = (int) (num14 + 1))
                                 {
                                     System.IO.FileInfo info2 = new System.IO.FileInfo(this.m_NoticeCache[str].get_Item(num14).CacheFilePath);
                                     if (info2.get_Exists())
                                     {
                                         byte[] bytes = System.IO.File.ReadAllBytes(info2.get_FullName());
                                         StiReport report4 = new StiReport();
                                         report4.LoadPackedDocument(bytes);
                                         report4.ReportUnit = report3.ReportUnit;
                                         foreach (StiPage page in report4.RenderedPages)
                                         {
                                             page.Report = report3;
                                             page.Guid = System.Guid.NewGuid().ToString().Replace("-", "");
                                             report3.RenderedPages.Add(page);
                                         }
                                         if (this.m_Exporter.DualPageExportMode && ((report4.RenderedPages.get_Count() % 2) != 0))
                                         {
                                             StiPage page2 = new StiPage(report3) {
                                                 IsRendered = true,
                                                 Orientation = report4.RenderedPages[0].Orientation,
                                                 Guid = System.Guid.NewGuid().ToString().Replace("-", "")
                                             };
                                             report3.RenderedPages.Add(page2);
                                         }
                                         builder.AppendLine(this.m_NoticeCache[str].get_Item(num14).FullAddress);
                                     }
                                 }
                                 report3.ExportDocument(StiExportFormat.Pdf, file);
                                 System.IO.File.WriteAllText(file + ".txt", builder.ToString());
                             }
                         }
                     }
                 }
                 logger.Info("Очистка дискового кэша");
                 System.IO.Directory.Delete(System.IO.Path.Combine(this.m_Exporter.DestinationPath, this.m_ExportCacheDirectoryName), true);
             }
             catch (System.Exception exception19)
             {
                 ex = new NoticeGenerationException("Ошибка при экспорте извещений, сгруппированных по УК", exception19);
                 this.AbortOperation(asyncOp, ex, (System.TimeSpan) (System.DateTime.Now - now));
                 return;
             }
         }
         System.TimeSpan timeSpent = (System.TimeSpan) (System.DateTime.Now - now);
         logger.Info("Операция успешно завершена. Время выполнения " + timeSpent.ToString());
         logger.Info("Всего отрендерено: " + ((int) this.m_TotalRendered));
         if (asyncOp != null)
         {
             GenerationCompletedEventArgs args = new GenerationCompletedEventArgs(timeSpent, null, false, asyncOp.get_UserSuppliedState()) {
                 GeneratedReport = report
             };
             asyncOp.PostOperationCompleted(this.onCompletedDelegate, args);
         }
         this.Reset();
     }
 }
开发者ID:u4097,项目名称:SQLScript,代码行数:101,代码来源:NoticeReportGenerator.cs

示例8: processCompletionMethod

        // This is the method that the underlying, free-threaded 
        // asynchronous behavior will invoke.  This will happen on
        // a worker thread
        private void processCompletionMethod(
            Task task,
            Exception exception,
            bool canceled,
            AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (processJobs)
                {
                    processJobs.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Package the results of the operation in EventArgs
            TaskEventArgs e = new TaskEventArgs(task, exception, canceled, asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible 
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onProcessingCompleteDelegate, e);

            // Note that after the call to OperationCompleted, 
            // asyncOp is no longer usable, and any attempt to use it
            // will cause an exception to be thrown.
        }
开发者ID:Jeff-Tian,项目名称:ocrsdk.com,代码行数:30,代码来源:RestServiceClientAsync.cs

示例9: PrepareToRaiseCreateContactCompletedEvent

 internal void PrepareToRaiseCreateContactCompletedEvent(AsyncOperation asyncOP, CreateContactCompletedEventArgs args)
 {
     asyncOP.PostOperationCompleted(OnCreateContactCompletedDelegate, args);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:4,代码来源:ContactManager.cs

示例10: completionMethod

 private void completionMethod(object data, Exception ex, bool cancelled, AsyncOperation asyncOp)
 {
     if (!cancelled) {
         lock (userStateToLifetime) {
             userStateToLifetime.Remove(asyncOp.UserSuppliedState);
         }
         var e = new OperationCompletedEventArgs(data, ex, cancelled, asyncOp.UserSuppliedState);
         asyncOp.PostOperationCompleted(onCompletedCallback, e);
     }
 }
开发者ID:esrgc,项目名称:etltool,代码行数:10,代码来源:DataCommit.cs

示例11: processFieldWorker

        private void processFieldWorker(string filePath, IProcessingSettings settings,
            AsyncOperation asyncOp)
        {
            Exception e = null;

            Task task = new Task();
            try
            {
                if (settings is TextFieldProcessingSettings)
                {
                    task = _syncClient.ProcessTextField(filePath, settings as TextFieldProcessingSettings);
                }
                else if (settings is BarcodeFieldProcessingSettings)
                {
                    task = _syncClient.ProcessBarcodeField(filePath, settings as BarcodeFieldProcessingSettings);
                }
                else if (settings is CheckmarkFieldProcessingSettings)
                {
                    task = _syncClient.ProcessCheckmarkField(filePath, settings as CheckmarkFieldProcessingSettings);
                }
                else
                {
                    throw new ArgumentException("Invalid type of processing settings");
                }

                // Notify that upload was completed
                Task uploadedTask = new Task(task.Id, TaskStatus.Submitted);
                UploadCompletedEventArgs uploadCompletedEventArgs = new UploadCompletedEventArgs(uploadedTask, asyncOp.UserSuppliedState);
                asyncOp.Post(onUploadCompletedDelegate, uploadCompletedEventArgs);

                // Wait until task finishes
                startTaskMonitorIfNecessary();

                _taskList.AddTask(task);
                task = waitUntilTaskFinishes(task);
            }
            catch (Exception ex)
            {
                e = ex;
            }

            lock (processJobs)
            {
                processJobs.Remove(asyncOp.UserSuppliedState);
            }

            bool canceled = false;

            // Package the results of the operation in EventArgs
            TaskEventArgs ev = new TaskEventArgs(task, e, canceled, asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible 
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onProcessingCompleteDelegate, ev);
        }
开发者ID:Jeff-Tian,项目名称:ocrsdk.com,代码行数:55,代码来源:RestServiceClientAsync.cs

示例12: RefreshWeaveDataCompletionMethod

        // This is the method that the underlying, free-threaded
        // asynchronous behavior will invoke.  This will happen on
        // an arbitrary thread.
        private void RefreshWeaveDataCompletionMethod(Exception error, bool cancelled, AsyncOperation asyncOperation)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!cancelled)
            {
                lock (this)
                {
                    userStateToLifetime.Remove(asyncOperation.UserSuppliedState);
                }
            }

            RefreshWeaveDataCompletedEventArgs e = new RefreshWeaveDataCompletedEventArgs(error, cancelled, asyncOperation.UserSuppliedState);
            asyncOperation.PostOperationCompleted(state => OnRefreshWeaveDataCompleted((RefreshWeaveDataCompletedEventArgs)state), e);
        }
开发者ID:pieterderycke,项目名称:CloudFox,代码行数:18,代码来源:Synchronizer.cs

示例13: GetBitmapWorker

        private void GetBitmapWorker(string path, AsyncOperation asyncOp)
        {
            Exception error = null;
            bool cancelled = false;
            Bitmap bitmap = null;

            try
            {
                bitmap = GetBitmap(path);
            }
            catch (Exception ex)
            {
                error = ex;
            }

            cancelled = IsTaskCanceled(asyncOp.UserSuppliedState);
            GetBitmapAsyncCancel(asyncOp.UserSuppliedState);
            asyncOp.PostOperationCompleted(getBitmapAsyncCompletedDelegate, new GetBitmapCompletedEventArgs(error, cancelled, asyncOp.UserSuppliedState, bitmap));
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:19,代码来源:GetBitmapManager.cs

示例14: InvokeOperationCompeted

        private void InvokeOperationCompeted(AsyncOperation asyncOp, SendOrPostCallback callback, UploadFileCompletedEventArgs eventArgs)
        {
            if (this.m_IsExpired)
                eventArgs = new UploadFileCompletedEventArgs("", new Exception(Properties.Settings.Default.UploadExpired), false, this.m_AsyncOperation.UserSuppliedState);

            if (Interlocked.CompareExchange<AsyncOperation>(ref this.m_AsyncOperation, null, asyncOp) == asyncOp)
            {
                var _originalWebResponse = Interlocked.Exchange<WebResponse>(ref this.m_WebResponse, null);
                closeResponse(_originalWebResponse);
                this.completeUploadClientState();
                asyncOp.PostOperationCompleted(callback, eventArgs);
            }
        }
开发者ID:dallagnese,项目名称:DownloadManager,代码行数:13,代码来源:UploadClientAzure.cs

示例15: ProcessWorker

        /// <summary>
        /// 异步工作线程。
        /// </summary>
        /// <param name="task">输入路径到输出路径</param>
        /// <param name="processingPlugins">处理插件</param>
        /// <param name="outputPlugin">输出插件</param>
        /// <param name="asyncOp">跟踪异步操作的生存期。</param>
        private void ProcessWorker(KeyValuePair<string, string> task, IEnumerable<IProcessingPlugin> processingPlugins, IOutputPlugin outputPlugin, AsyncOperation asyncOp)
        {
            // 创建处理任务上下文对象。
            ImageProcessorTaskContext imageProcessorTaskContext = new ImageProcessorTaskContext();
            imageProcessorTaskContext.TotalProcedureCount = processingPlugins.Count() + 2;

            // 为 ProcessingPlugin 添加事件处理方法。
            foreach (var processingPlugin in processingPlugins)
            {
                // ! 重要,保证多任务处理事件唯一,也许以后可能有更好的方法。
                lock (processingPlugin)
                {
                    processingPlugin.ProcessProgressChanged -= processingPlugin_ProcessProgressChangedDelegate;
                    processingPlugin.ProcessCompleted -= getBitmapCompletedDelegate;
                    processingPlugin.ProcessProgressChanged += processingPlugin_ProcessProgressChangedDelegate;
                    processingPlugin.ProcessCompleted += getBitmapCompletedDelegate;
                }
                imageProcessorTaskContext.ProcessingPluginQueue.Enqueue(processingPlugin);
            }

            // 添加到对应关系中。
            lock ((userStateToTaskContext as ICollection).SyncRoot)
            {
                userStateToTaskContext[asyncOp.UserSuppliedState] = imageProcessorTaskContext;
            }

            // 创建 UserState 对象。
            object userState = Guid.NewGuid();

            // 添加到对应关系中。
            lock ((taskUserStateToUserState as ICollection).SyncRoot)
            {
                taskUserStateToUserState[userState] = asyncOp.UserSuppliedState;
            }

            // 开始获取 Bitmap。
            getBitmapManager.GetBitmapAsync(task.Key, userState);

            while (imageProcessorTaskContext.ProcessingPluginQueue.Count > 0)
            {
                // 等待上步操作完成。
                imageProcessorTaskContext.AutoResetEvent.WaitOne();

                if (IsTaskCancelled(asyncOp.UserSuppliedState) || imageProcessorTaskContext.Error != null)
                {
                    break;
                }
                else
                {
                    IProcessingPlugin processingPlugin = imageProcessorTaskContext.ProcessingPluginQueue.Dequeue();
                    userState = Guid.NewGuid();
                    imageProcessorTaskContext.CurrentProcessingPlugin = processingPlugin;
                    imageProcessorTaskContext.CurrentProcessingPluginUserState = userState;

                    lock ((taskUserStateToUserState as ICollection).SyncRoot)
                    {
                        taskUserStateToUserState[userState] = asyncOp.UserSuppliedState;
                    }
                    processingPlugin.ProcessAsync(imageProcessorTaskContext.Bitmap, userState);
                }
            }

            if (!IsTaskCancelled(asyncOp.UserSuppliedState) && imageProcessorTaskContext.Error == null)
            {
                // 等待最后处理完成。
                imageProcessorTaskContext.AutoResetEvent.WaitOne();

                // 输出。
                outputPlugin.Output(imageProcessorTaskContext.Bitmap, task.Value);
            }

            bool cancelled = IsTaskCancelled(asyncOp.UserSuppliedState);
            lock ((userStateToLifetime as ICollection).SyncRoot)
            {
                userStateToLifetime.Remove(asyncOp.UserSuppliedState);
            }
            asyncOp.PostOperationCompleted(processAsyncCompletedDelegate, new AsyncCompletedEventArgs(imageProcessorTaskContext.Error, cancelled, asyncOp.UserSuppliedState));
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:85,代码来源:ImageProcessor.cs


注:本文中的System.ComponentModel.AsyncOperation.PostOperationCompleted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。