"景先生毕设|www.jxszl.com

C# ActionBlock类代码示例

2023-12-29 16:57编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中ActionBlock类的典型用法代码示例。如果您正苦于以下问题:C# ActionBlock类的具体用法?C# ActionBlock怎么用?C# ActionBlock使用的例子? 这里精选的类代码示例或许可以为您提供帮助。 示例1: Engine public Engine(IWorkItemRepository repository, IActivityRunner activityRunner, IStateMachineProvider stateMachineProvider) { if (repository == null) throw new ArgumentNullException("repository"); if (activityRunner == null) throw new ArgumentNullException("activityRunner"); if (stateMachineProvider == null) throw new ArgumentNullException("stateMachineProvider"); _repository = repository; _activityRunner = activityRunner; _stateMachineProvider = stateMachineProvider; _stateQueue = new ActionBlock(id => UpdateState(id), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 }); _workerQueue = new ActionBlock(id => RunActivity(id), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = int.MaxValue }); _stateQueue.Completion.ContinueWith(t => { _workerQueue.Complete(); }, TaskContinuationOptions.OnlyOnFaulted); _workerQueue.Completion.ContinueWith(t => { ((IDataflowBlock) _stateQueue).Fault(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted); }
原文链接:http://www.jxszl.com/biancheng/C/556453.html