public StartableBlock <DataBatch <Person> > Create(string targetFilePath1, string targetFilePath2, IProgress <PipelineProgress> progress, CancellationToken cancellation) { var pipeline1 = _pipelineFactory.Create(targetFilePath1, progress, cancellation); var pipeline2 = _pipelineFactory.Create(targetFilePath2, progress, cancellation); return(new StartableBlock <DataBatch <Person> >(() => { pipeline1.Start(); pipeline2.Start(); }, pipeline2.Output, pipeline2.EstimatedOutputCount, Task.WhenAll(pipeline1.Completion, pipeline2.Completion), true)); }
/// <summary> /// Creates an <see cref="IPipeline"/> with the given participant configuration ID containing the specified participants. /// </summary> /// <remarks> /// <see cref="IPipeline"/> instances with equal participant configuration IDs must generate equivalent types. /// </remarks> /// <param name="pipelineFactory">The <see cref="IPipelineFactory"/> to use for creation. Usually retrieved from the application's IoC container.</param> /// <param name="participantConfigurationID">The participant configuration ID.</param> /// <param name="participants">The participants that should be used by this object factory.</param> /// <returns>An new instance of <see cref="IPipeline"/>.</returns> public static IPipeline Create(this IPipelineFactory pipelineFactory, string participantConfigurationID, params IParticipant[] participants) { ArgumentUtility.CheckNotNull("pipelineFactory", pipelineFactory); ArgumentUtility.CheckNotNullOrEmpty("participantConfigurationID", participantConfigurationID); ArgumentUtility.CheckNotNullOrItemsNull("participants", participants); return(pipelineFactory.Create(participantConfigurationID, PipelineSettings.Defaults, participants)); }
private static void RunPipeline() { using (var cancellation = new CancellationTokenSource()) { Task.Run(() => WaitForCancellation(cancellation)); var progress = new Progress <PipelineProgress>(x => Console.WriteLine($"{x.Percentage}% processed.")); var pipeline = _pipelineFactory.Create(Settings.PeopleTargetFilePath, progress, cancellation.Token); var executionResult = _pipelineExecutor.Execute(pipeline).Result; HandleExecutionResult(executionResult); } }