示例#1
0
        static public void ActiveTimer()
        {
            //checking if there are new active windows by comparing PID's in list to ProcessInfo current PID , if there is -catching exeption and creating new component , if not - incrementing time field

            try
            {
                int i = StatWatcherList.FindIndex(Watcher => Watcher.Pid == ProcessInfo.Pid);

                StatWatcherList[i].label.Text = ProcessInfo.MainWindowTitle + $" has been opened for {(StatWatcherList[i].time < 60 ? StatWatcherList[i].time + " seconds" : (StatWatcherList[i].time < 3600 ? (StatWatcherList[i].time / 60) + " minutes" : (StatWatcherList[i].time < 216000 ? (StatWatcherList[i].time / 3600) + " hours" : "")))}";
                StatWatcherList[i].time      += 10;
                StatWatcherList[i].panel.Update();
            }
            catch (ArgumentOutOfRangeException)
            {
                PointY += 50;
                StatWatcher NewInstance = new StatWatcher(StatWatcherList[0].ExternalPanel, PointY);
            }
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();
            StatWatcher st = new StatWatcher(panel1);

            //timer that invokes form  and ProcessInfo update  every 10 second

            tTimer timer = new tTimer(10000);

            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Elapsed  += new ElapsedEventHandler(TimerEvent);



            void TimerEvent(object source, ElapsedEventArgs e)
            {
                ProcessInfo.UpdateValues();
                UpdateDelegate TimerDelegate = StatWatcher.ActiveTimer;

                Invoke(TimerDelegate);
            }
        }