System.Collections.Concurrent.ConcurrentBag.Add(IExecutionPipelineContext)

Here are the examples of the csharp api class System.Collections.Concurrent.ConcurrentBag.Add(IExecutionPipelineContext) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: Zongsoft.CoreLibrary
Source File: Executor.cs
protected virtual object InvokePipelines(IEnumerable<ExecutionPipeline> pipelines, Func<ExecutionPipeline, ExecutionPipelineContext> createContext)
		{
			if(pipelines == null)
				return null;

			//?????????
			var pipelineContexts = new ConcurrentBag<IExecutionPipelineContext>();

			var parallelling = System.Threading.Tasks.Parallel.ForEach(pipelines, pipeline =>
			{
				//??????????????????????????
				if(pipeline.Handler == null)
					return;

				//?????????
				var pipelineContext = createContext(pipeline);

				//?????????????
				var isHandled = false;

				try
				{
					//??????
					isHandled = this.InvokePipeline(pipelineContext);
				}
				catch(Exception ex)
				{
					pipelineContext.Exception = ex;
				}

				if(isHandled)
					pipelineContexts.Add(pipelineContext);
			});

			object result = null;

			if(parallelling.IsCompleted)
			{
				//???????????????????????????
				result = this.CombineResult(pipelineContexts);
			}

			return result;
		}