Пример #1
0
        public override void RunInGuiThread(System.Action d)
        {
            if (alreadyInGuiThread)
            {
                Console.WriteLine();
                Console.WriteLine("WARNING: You called RunInGuiThread nestedly.");
                d();
                return;
            }
            alreadyInGuiThread = true;

            try {
                System.Threading.EventWaitHandle h = guiThread.CallDelegInMainLoop(d);
                h.WaitOne();
                h.Close();
                if (guiThread.ExceptionHappened != null)
                {
                    throw guiThread.ExceptionHappened;
                }
            }
            finally {
                alreadyInGuiThread = false;
            }
            System.Threading.Thread.Sleep(2000);
        }
Пример #2
0
 /// <summary>
 /// Disposing the object
 /// </summary>
 public void Dispose()
 {
     if (CmdSignal != null)
     {
         CmdSignal.Close();
         CmdSignal = null;
     }
 }
Пример #3
0
 static void Main(string[] args)
 {
     System.Configuration.Install.InstallContext _args = new System.Configuration.Install.InstallContext(null, args);
     if (_args.IsParameterTrue("debug"))
     {
         System.Console.WriteLine("wait for debugger, press any key to continue...");
         System.Console.ReadKey();
     }
     if (_args.IsParameterTrue("start-server"))
     {
         bool own = false;
         System.Threading.EventWaitHandle evt = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, TAG, out own);
         if (own)
         {
             start_server(evt, _args.Parameters);
         }
         else
         {
             // server already running.
         }
     }
     else if (_args.IsParameterTrue("kill-server"))
     {
         try
         {
             System.Threading.EventWaitHandle evt = System.Threading.EventWaitHandle.OpenExisting(TAG);
             evt.Set();
             evt.Close();
         }
         catch (Exception) { }
     }
     else
     {
         test();
     }
 }
Пример #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //if(videoSource!=null)
            //{
            //    videoSource.SimulateTrigger();

            //}
            //if (vc != null)
            //{
            //    Mat m = vc.QueryFrame();
            //    pictureBox1.Invoke(new MethodInvoker(delegate
            //    {
            //        pictureBox1.Image = m.Bitmap;
            //    }));
            //}
            string   fn  = @"C:\projects\local\xindawn-airplay-sdk-example\screen.jpeg";
            DateTime l   = DateTime.Now - new TimeSpan(0, 1, 0);
            Bitmap   bmp = null;

            try
            {
                if (System.IO.File.Exists(fn))
                {
                    l = System.IO.File.GetLastWriteTime(fn);
                }
                System.Threading.EventWaitHandle evt = System.Threading.EventWaitHandle.OpenExisting(@"Global\captureimage");
                evt.Set();
                evt.Close();
                DateTime _s = DateTime.Now;
                do
                {
                    if (System.IO.File.Exists(fn))
                    {
                        DateTime _l = System.IO.File.GetLastWriteTime(fn);
                        if (_l > l)
                        {
                            try
                            {
                                using (var bmpTemp = new Bitmap(fn))
                                {
                                    bmp = new Bitmap(bmpTemp);
                                }
                                //bmp = new Bitmap(fn);
                                break;
                            }
                            catch (Exception) { }
                        }
                    }
                } while ((DateTime.Now - _s).TotalSeconds < 3);
                if (bmp != null)
                {
                    pictureBox1.Invoke(new MethodInvoker(delegate
                    {
                        try
                        {
                            pictureBox1.Image = bmp;
                        }
                        catch (Exception ex)
                        {
                            Program.logIt(ex.Message);
                            Program.logIt(ex.StackTrace);
                        }
                    }));
                }
            }
            catch (Exception ex)
            {
                Program.logIt(ex.Message);
                Program.logIt(ex.StackTrace);
            }
        }