static void Main(string[] args) { TaskEngine.Run("HW", () => { Console.WriteLine("Sup"); }); TaskEngine.Run("HW", () => { Console.WriteLine("Yo"); }); var x = TaskEngine.GetTask("HW"); TaskEngine.WaitAll(); _ = 5; }
/// <summary> /// Perform a benchmark and display performance metrics. /// </summary> void Benchmark(Benchmarks.Benchmark benchmark) { int secs = seconds.Value; DateTime endTime = DateTime.Now + TimeSpan.FromSeconds(secs); int steps = 0; runner.Run(() => { DateTime now = DateTime.Now; while (now < endTime) { ++steps; benchmark.Step(); now = DateTime.Now; runner.UpdateProgressBar(1 - (endTime - now).TotalSeconds / secs); } MessageBox.Show($"Performed {steps} steps in {secs} seconds. " + $"Performance: {steps / (float)secs:0.0} operations/second.", "Benchmark finished"); }); }
/// <summary> /// Begin the export process with selecting the output name. /// </summary> void Export(object _, RoutedEventArgs e) { SaveFileDialog dialog = new() { Filter = dialogFilter }; if (dialog.ShowDialog() == true) { if (dialog.FileName == loadedFile) { ShowError("Can't overwrite the source file with the exported file."); } else { process.Run(() => ExportProcess(dialog.FileName)); } } } }
public void Handle(IGluonSession session, RequestTask task) { var shardId = new Nullable <int>(); if (task.ShardId > 0) { shardId = task.ShardId; } var id = TaskEngine.Run(new TaskRunOptions() { Task = task.TaskType, Shard_Id = shardId, Parameter = JsonConvert.DeserializeObject(task.ParameterJson) }); session.Write(new RequestTaskResponse() { CallId = task.CallId, TaskId = id }); }