// Сконструировать новый поток. public MyThread(string name, TickTock tt) { Thrd = new Thread(this.Run); ttOb = tt; Thrd.Name = name; Thrd.Start(); }
static void Main() { TickTock tt = new TickTock(); MyThread mtl = new MyThread("Tick", tt); MyThread mt2 = new MyThread("Tock", tt); mtl.Thrd.Join(); mt2.Thrd.Join(); Console.WriteLine("Часы остановлены"); }
private void _timer_Elapsed(object sender, ElapsedEventArgs e) { if (DateTime.Now >= _startTime.AddSeconds(CountdownSeconds)) { End(); } else { Tuple <double, string> value = GetValue(); TickTock?.Invoke(this, new CountdownEventArgs(value.Item2, value.Item1)); } }
static void Main() { TickTock tt = new TickTock(); MyThread mt1 = new MyThread("Tick", tt); MyThread mt2 = new MyThread("Tock", tt); mt1.Thrd.Join(); mt2.Thrd.Join(); Console.WriteLine("Clock Stopped"); }
public async Task <object> ActionTest(TimersFilter filter) { var stopWatch = TickTock.StartNew("Json parse"); var json = Mongo.GroupTimers( filter.info.Test, filter.info.Mesh, filter.info.Benchmark, "whole-program", filter.info.Branch ?? "master" ); stopWatch.Start("MongoDB Aggregate"); var items = await _dbService.ColTimers .Aggregate <GroupedTimer>(json.AsBsonArray()) .ToListAsync(); stopWatch.Start("Welch Compute"); TimerUtils.ComputeWelch(items); TimerUtils.SmoothDetections(items); stopWatch.Start("Transform Timer"); var result = items .Select(i => new SimpleTimers { Durations = i.Durations.ToArray(), Commit = i.Commit, Branch = i.Info.Branch, Welch = i.Welch, Left = i.Left, Right = i.Right, Info = GitInfo.From(i.Info), isBroken = false, }) .ToList(); stopWatch.Stop(); return(new { Data = result, Ratio = 0.2 }); }
public Stepan(TickTock time) { time.RockAroundTheClock += Birthday; }
public void Unregister(TickTock time) { time.RockAroundTheClock -= Boom; }
public TooLate(TickTock time) { time.RockAroundTheClock += Boom; }
static void Main() { TickTock time = new TickTock(); TooLate die = null; Stepan stepan = null; bool wannaBreak = false; while (true) { Console.WriteLine(menu); string response = Console.ReadLine(); int result; if (int.TryParse(response, out result) && result >= 1 && result <= 6) { switch (result) { case 1: Console.WriteLine("Enter time in milliseconds"); string responsedTime = Console.ReadLine(); int resultTime; if (int.TryParse(responsedTime, out resultTime)) { time.SetTheFinalCountDown(resultTime); } else { Console.WriteLine("Bad decision!"); } break; case 2: die = new TooLate(time); break; case 3: die?.Unregister(time); break; case 4: stepan = new Stepan(time); break; case 5: stepan?.Unregister(time); break; case 6: wannaBreak = true; break; } if (wannaBreak) { break; } } else { Console.WriteLine("Bad decision!"); } } }
public void Unregister(TickTock time) { time.RockAroundTheClock -= Birthday; }