示例#1
0
 // Сконструировать новый поток.
 public MyThread(string name, TickTock tt)
 {
     Thrd = new Thread(this.Run);
     ttOb = tt;
     Thrd.Name = name;
     Thrd.Start();
 }
示例#2
0
 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("Часы остановлены");
 }
示例#3
0
 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));
     }
 }
示例#4
0
    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");
    }
示例#5
0
        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
            });
        }
示例#6
0
 public Stepan(TickTock time)
 {
     time.RockAroundTheClock += Birthday;
 }
示例#7
0
 public void Unregister(TickTock time)
 {
     time.RockAroundTheClock -= Boom;
 }
示例#8
0
 public TooLate(TickTock time)
 {
     time.RockAroundTheClock += Boom;
 }
示例#9
0
        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!");
                }
            }
        }
示例#10
0
 public void Unregister(TickTock time)
 {
     time.RockAroundTheClock -= Birthday;
 }