Пример #1
0
        static void Officemonitor()
        {
            OfficeMonitor om     = new OfficeMonitor();
            bool          stop   = false;
            Thread        thread = new Thread(new ThreadStart(() => {
                while (!stop)
                {
                    bool flag = false;
                    var res   = om.GetFilesEx();
                    if (res == null)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    foreach (var r in res)
                    {
                        w(r);
                    }
                    if (res.Count == 0)
                    {
                        w("none");
                    }
                    var pros = Process.GetProcessesByName("WINWORD");
                    w(pros.Length);
                    Thread.Sleep(1000);
                    w("------");
                }
            }));

            thread.Start();

            var key = Console.ReadLine();

            if (key == "q")
            {
                stop = true;
            }
            else
            {
                stop = stop ? false : true;
                if (!stop)
                {
                    thread.Start();
                }
                key = Console.ReadLine();
            }
        }
 public virtual Monitor makeMonitor()
 {
     Monitor theMonitor;
     //Choose a monitor from the current options randomly
     Random rnd = new Random();
     int choose = rnd.Next(1, 3);
     switch (choose)
     {
         case 1:
             theMonitor = new OfficeMonitor();
             break;
         case 2:
         default:
             theMonitor = new RecycledMonitor();
             break;
     }
     return theMonitor;
 }