コード例 #1
0
        private static void SimulationEngineExecute(ProjectHLK project, string outputs, int cores, HowLeakyOutputType outputType, int?targetindex, Action onSuccess = null)
        {
            var controller = new SimulationController();
            var myprogress = new GlobalProgress(project.Simulations.Count);

            myprogress.StartSimulations();
            var tokenSource      = new CancellationTokenSource();
            CancellationToken ct = tokenSource.Token;

            project.OutputsCSV = outputs;
            project.AddConsoleOutput("Running simulations... please wait...");
            //var runSimulationsTask = Task.Run(() => Controller.Execute(CurrentProject, MyProgress));
            var taskList = new System.Collections.Generic.List <Task>();

            taskList.Add(Task.Factory.StartNew(delegate
            {
                controller.Execute(project, tokenSource, cores, targetindex, outputType, myprogress);
            }, tokenSource.Token)); // Pass same token to StartNew.
            Task.WaitAll(taskList.ToArray());
        }
コード例 #2
0
 public GlobalProgressResult ActivateGlobalProgress(Action <GlobalProgressActionArgs> progresAction, GlobalProgressOptions progressArgs)
 {
     return(Invoke(() => GlobalProgress.ActivateProgress(progresAction, progressArgs)));
 }