コード例 #1
0
ファイル: Main.cs プロジェクト: abhinavc/scanbotOnWin
        public static void Main(string[] args)
        {
            Application.Init ();

             appWindow = new MainWindow() ;
             appWindow.Show ();

             doPrepWork() ;

             detector = new Thread(new ThreadStart(Detector.start)) ;
             transmitter = new Thread(new ThreadStart(Transmitter.start)) ;

             // 45 minutes = 45 min x 60 s/min x 1000 ms/s = 2,700,000 ms
             tickTock = new System.Timers.Timer(2700000) ;
             tickTock.Elapsed += new ElapsedEventHandler(RestartThreads) ;
             tickTock.Enabled = true ;

             detector.Start() ;
             transmitter.Start() ;

             Application.Run ();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: abhinavc/Scanbot-WF
        static void Main()
        {
            // Ensure that only one instance of the Scanbot is alive at any time.
              // If a request comes for launching a second, then simply return from here
              // Ref: http://www.codeproject.com/Articles/32908/C-Single-Instance-App-With-the-Ability-To-Restore

              bool  onlyInstance = false;
              Mutex m = new Mutex(true, @"dublin_delhi_damascus", out onlyInstance);
              if (!onlyInstance) {
            System.Diagnostics.Debug.WriteLine("[start-up]: Another running instance detected");
            return;
              }

              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);

              // Ordinarily, an app would have an elaborate initialization routine during
              // which the splash screen would be shown. We don't. And hence, life is
              // simpler for us. We can just flash the splash and let MainWindow load
              // behind it. All that we have to do is close the splash after 5-6 seconds

              // 3 seconds = 3000 ms

              splashTimer = new System.Timers.Timer(3000);
              splashScreen = new Splash();
              splashTimer.Elapsed += new ElapsedEventHandler(CloseSplash);
              splashScreen.Show();
              splashTimer.Enabled = true;

              // Now, load the main application window behind the splash screen
              Gui = new MainWindow();
              doPrepWork();
              Gui.setVersion();

              Application.Run(Gui);
              GC.KeepAlive(m);
              // very important for ensuring that only one instance of scanbot is ever alive
              // And the call to KeepAlive has to be the last call
              // See http://msdn.microsoft.com/en-us/library/system.gc.keepalive.aspx to know why
        }