Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Custom Dashboards and the Driver Station Software (http://www.chiefdelphi.com/forums/showthread.php?t=84775)

slavik262 01-04-2010 01:02

Re: Custom Dashboards and the Driver Station Software
 
Great to hear we found out what the problem was. In the meantime, a simple launchpad that prevents multiple instances can be downloaded from the CARDS FIRST Forge site at

http://firstforge.wpi.edu/sf/frs/do/...board_launcher

byteit101 01-04-2010 19:50

Re: Custom Dashboards and the Driver Station Software
 
this sounds strangely similar to an article I read about a disabled watchdog for testing...

ZomB v0.5 will have a DashboardDataHubForm that prevents multiple instances via a system mutex. Not sure how CARDS does it
(From: http://firstforge.wpi.edu/integratio...&view =markup )
PHP Code:

[DllImport("user32.dll")]
[return: 
MarshalAs(UnmanagedType.Bool)]
static 
extern bool SetForegroundWindow(IntPtr hWnd);

...
            
//Check Singleton
            
bool createdNew true;
//Create System Mutex. createNew is false if this already exists
            
mutex = new Mutex(true"ZomBSingletonMutex"out createdNew);

            if ((!
createdNew) && (!DesignMode))
            {
                
Process current Process.GetCurrentProcess();
                
//Don't kill designer
                
if (/*Don't kill designer test here*/)
                {
                    foreach (
Process process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (
process.Id != current.Id)
                        {
                            
//focus other
                            
SetForegroundWindow(process.MainWindowHandle);
                            break;
                        }
                    }
                    
current.Kill();//suicide
                
}
            } 

Its already in the r19 Nightly: http://firstforge.wpi.edu/sf/frs/do/...able.v0_4_1_19

slavik262 02-04-2010 01:20

Re: Custom Dashboards and the Driver Station Software
 
The initial version I released last night used a file for a lock, but after some trial by fire this morning at the North Star regional, it now uses a named mutex. Great minds seem to think alike. :D


All times are GMT -5. The time now is 23:21.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi