private void Initialize() { if (_downloadManager == null) { _downloadManager = DownloadManager.Instance; } if (_elevator == null) { _elevator = Elevator.Instance; _elevator.ElevationRequested += OnElevationRequested; } if (_downloads == null) { var workers = ParallelDownload; Logger?.Trace($"Concurrent downloads: {workers}"); _downloads = new AsyncTaskRunner(workers); _downloads.Error += OnError; } if (_installs == null) { _installs = new TaskRunner.TaskRunner(); _installs.Error += OnError; } }
public AsyncTaskRunnerBuilder <R> OnCompletion(AsyncTaskRunner <R> .OnWorkCompleted onWorkCompleted) { if (runner == null) { this.onWorkCompleted = onWorkCompleted; } return(this); }
public AsyncTaskRunnerBuilder <R> OnError(AsyncTaskRunner <R> .OnError onError) { if (runner == null) { this.onError = onError; } return(this); }
public AsyncTaskRunnerBuilder <R> Do(AsyncTaskRunner <R> .DoInBackground doInBackground) { if (runner == null) { this.doInBackground = doInBackground; } return(this); }
public void Run(params object[] args) { if (runner == null) { runner = new AsyncTaskRunner <R> (retryCount, retryDelay, doInBackground, onWorkCompleted, onError); } runner.Run(args); }
public Debugger(AsyncTaskRunner asyncTaskRunner) { Dispatch.AsyncTaskRunner = asyncTaskRunner; this.BreakpointList = new BreakpointList(this); this.Memory = new Memory(this); this.ModuleList = new ModuleList(this); this.ThreadList = new ThreadList(this); this.CurrentContext = new Context(this); }
public Debugger(AsyncTaskRunner asyncTaskRunner) { Dispatch.AsyncTaskRunner = asyncTaskRunner; this.BreakpointList = new BreakpointList(this); this.Memory = new Memory(this); this.ModuleList = new ModuleList(this); this.ThreadList = new ThreadList(this); this.CurrentContext = new Context(this); }
public async Task InitAsync(IRuntime runtime) { logger = runtime.Container.Resolve <ILogger>(); await runtime.Container.Resolve <IPluginLoader>().InitAsync(); var taskScheduler = runtime.Container.Resolve <ITaskScheduler>(); syncTaskRunner = new AsyncTaskRunner(taskScheduler, ExecutionTargetSide.SyncFrame); syncTaskRunner.Start(); physicsTaskRunner = new AsyncTaskRunner(taskScheduler, ExecutionTargetSide.SyncFrame); physicsTaskRunner.Start(); ICommandHandler cmdHandler = runtime.Container.Resolve <ICommandHandler>(); Directory.SetCurrentDirectory(WorkingDirectory); logger.LogInformation("Loaded; type \"help\" for help or \"exit\" to exit."); System.Console.ForegroundColor = ConsoleColor.Gray; System.Console.Write("> "); System.Console.ForegroundColor = ConsoleColor.White; string line; while (!(line = System.Console.ReadLine())?.Equals("exit", StringComparison.OrdinalIgnoreCase) ?? false) { if (string.IsNullOrEmpty(line)) { continue; } try { if (!await cmdHandler.HandleCommandAsync(Console, line, "")) { System.Console.WriteLine("Command not found: " + line); } System.Console.Write("> "); } catch (Exception ex) { Console.WriteLine(ex.ToString(), Color.DarkRed); } } Environment.Exit(0); }
public async Task ShouldRunAllAsyncTasks(int maxDegreeOfParallelism, int taskCount) { // Setup var testAsyncTaskStatuses = new Dictionary <int, bool>(); var asyncTaskRunner = new AsyncTaskRunner <TestAsyncTask>(maxDegreeOfParallelism, CancellationToken.None); for (int i = 0; i < taskCount; i++) { testAsyncTaskStatuses.Add(i, false); asyncTaskRunner.AddTask(new TestAsyncTask(i, task => { lock (_lock) { testAsyncTaskStatuses[task.TaskId] = true; } })); } // Act await asyncTaskRunner.WaitForCompletion(); // Assert testAsyncTaskStatuses.ShouldAllBe(s => s.Value); }
public CleanOperation() { _taskRunner = new AsyncTaskRunner(ConcurrentClean); _taskRunner.Error += OnCleaningError; _cleanFileTasks = new List <CleanFileTask>(); }
public async Task DeployDacPac(IReadOnlyCollection <DatabaseInfo> databases, CancellationToken cancellationToken) { var buildServer = _buildServerResolver.Resolve(); _log.Debug("Starting DacPac Deployment Tasks with {0} {1}.", _arguments.Threads, _arguments.Threads == 1 ? "thread" : "threads"); int completedTasks = 0; int failedTasks = 0; int totalTasks = databases.Count; var asyncTaskRunner = new AsyncTaskRunner <DacPacDeployAsyncTask>(_arguments.Threads, cancellationToken); foreach (var database in databases) { var dacPacDeployAsyncTask = _dacPacDeployAsyncTaskFactory.CreateAsyncTask(); dacPacDeployAsyncTask.Setup(database, (task, successful, elapsedMilliseconds) => { Interlocked.Increment(ref completedTasks); _log.Debug("Completed {0} out of {1} tasks.", completedTasks, totalTasks); if (!successful) { Interlocked.Increment(ref failedTasks); _log.Warning("{0} out of {1} tasks have failed.", failedTasks, totalTasks); } if (buildServer != null) { _log.WriteRaw(LogLevel.Info, buildServer.GenerateSetProgressMessage(completedTasks, totalTasks, "Progress Update")); } }); asyncTaskRunner.AddTask(dacPacDeployAsyncTask); } await asyncTaskRunner.WaitForCompletion(); if (failedTasks == totalTasks) // If all Tasks Failed { _log.Error("All Deployment Tasks Failed"); if (buildServer != null) { _log.WriteRaw(LogLevel.Error, buildServer.GenerateSetStatusFailMessage("All Deployment Tasks Failed")); } } else if (failedTasks > 0) // If any Tasks Failed { _log.Warning("Some Deployment Tasks Failed"); if (buildServer != null) { _log.WriteRaw(LogLevel.Warn, buildServer.GenerateSetStatusSucceededWithIssuesMessage("Some Deployment Tasks Failed")); } } else // If all Tasks Succeeded { _log.Info("All Deployment Tasks Succeeded"); if (buildServer != null) { _log.WriteRaw(LogLevel.Info, buildServer.GenerateSetStatusSucceededMessage("All Deployment Tasks Succeeded")); } } }