c# - Start Application only once (Mono) -


i'm developing mono application in c#, start once. know, can achieved mutex. how can bring application front using mono? tried getting process via

process.getprocessbyname("audiocuesheeteditor") 

but couldn't access mainwindowhandle.

how can bring running application front?

thanks answers.

edit:

now have been able mainwindowhandle, it's intptr. how bring handle front? tried

window wrunning = new window(handle); wrunning.present(); 

but gave me exception :(.

i have been able fix file system watcher:

        filesystemwatcher fswrunning = new filesystemwatcher(path.gettemppath() + "audiocuesheeteditor");         fswrunning.filter = "*.txt";         fswrunning.changed += delegate(object sender, filesystemeventargs e) {             log.debug("filesystemwatcher called changed");             if (paudiocuesheeteditor != null)             {                 log.debug("paudiocuesheeteditor != null");                 paudiocuesheeteditor.getobjmainwindow().present();             }         };         fswrunning.enableraisingevents = true;         boolean balreadyrunning = false;         process[] arrprunning = process.getprocesses();         foreach (process prunning in arrprunning)         {             boolean bcheckprocessmatch = false;             if (environment.osversion.platform == platformid.unix)             {                 if (prunning.hasexited == false)                 {                     log.debug("prunning.processname = " + prunning.processname + " prunning.mainwindowtitle = " + prunning.mainwindowtitle);                     if (prunning.processname.tolower().contains("mono"))                     {                         (int = 0; < prunning.modules.count;i++)                         {                             if (prunning.modules[i].modulename.contains("audiocuesheeteditor"))                             {                                 bcheckprocessmatch = true;                                 = prunning.modules.count;                             }                         }                     }                 }             }              else             {                 log.debug("prunning.processname = " + prunning.processname);                 if (prunning.processname == process.getcurrentprocess().processname)                 {                     bcheckprocessmatch = true;                 }             }             log.debug("bcheckprocessmatch == " + bcheckprocessmatch);             if ((prunning.id != process.getcurrentprocess().id) && (bcheckprocessmatch == true))             {                 log.info("writing file " + path.gettemppath() + "audiocuesheeteditor" + path.directoryseparatorchar + "message.txt");                 file.writealltext(path.gettemppath() + "audiocuesheeteditor" + path.directoryseparatorchar + "message.txt","present");                 balreadyrunning = true;             }         }         log.debug("balreadyrunning = " + balreadyrunning);         if (balreadyrunning == false)         {                //start application         } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -