internal static void Main(string[] args) { try { Registrar.CanInit = true; // Make our app a foreground app (this is redundant if we were started via the // Finder or the open command, but important if we were started by directly // executing the launcher script). var psn = new ProcessSerialNumber(); psn.highLongOfPSN = 0; psn.lowLongOfPSN = kCurrentProcess; int err = TransformProcessType(ref psn, kProcessTransformToForegroundApplication); if (err != 0) throw new InvalidOperationException("TransformProcessType returned " + err + "."); err = SetFrontProcess(ref psn); if (err != 0) throw new InvalidOperationException("SetFrontProcess returned " + err + "."); // Load the nib and run the main event loop. NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool")); App app = new App("MainMenu.nib"); pool.release(); app.Run(); } catch (Exception e) { Console.WriteLine(e); } }
public static void TestPid() { var psn = new ProcessSerialNumber(0, 2 /* kCurrentProcess */); int pid = ProcessManager.GetProcessPid(psn); Assert.AreNotEqual(-1, pid); }
static NSApplication() { // Make our app a foreground app (this is redundant if we were started via the // Finder or the open command, but important if we were started by directly // executing the launcher script). var psn = new ProcessSerialNumber(); psn.highLongOfPSN = 0; psn.lowLongOfPSN = kCurrentProcess; int err = TransformProcessType(ref psn, kProcessTransformToForegroundApplication); if (err != 0 && err != paramErr) throw new InvalidOperationException("TransformProcessType returned " + err + "."); // On Lion we don't have to do the TransformProcessType (and we get a paramErr when // we try). err = SetFrontProcess(ref psn); if (err != 0) throw new InvalidOperationException("SetFrontProcess returned " + err + "."); // Cocoa expects an NSAutoreleasePool to always be available so we need to // create one which we can use before we enter the main event loop. ms_startupPool = NSAutoreleasePool.Create(); }
internal static void Main(string[] args) { try { Registrar.CanInit = true; // Make our app a foreground app (this is redundant if we were started via the // Finder or the open command, but important if we were started by directly // executing the launcher script). var psn = new ProcessSerialNumber(); psn.highLongOfPSN = 0; psn.lowLongOfPSN = kCurrentProcess; int err = TransformProcessType(ref psn, kProcessTransformToForegroundApplication); if (err != 0) { throw new InvalidOperationException("TransformProcessType returned " + err + "."); } err = SetFrontProcess(ref psn); if (err != 0) { throw new InvalidOperationException("SetFrontProcess returned " + err + "."); } // Load the nib and run the main event loop. NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool")); App app = new App("MainMenu.nib"); pool.release(); app.Run(); } catch (Exception e) { Console.WriteLine(e); } }
static extern int CPSSetProcessName(ref ProcessSerialNumber psn, string name);
static extern int GetCurrentProcess(out ProcessSerialNumber psn);
private static extern short SetFrontProcess(ref ProcessSerialNumber psn);
private static extern int TransformProcessType(ref ProcessSerialNumber psn, uint type);
public MonoMacProcess (ProcessSerialNumber psn, Tail outTail, Tail errTail) { this.psn = psn; this.pid = ProcessManager.GetProcessPid (psn); if (pid < 0) throw new Exception (string.Format ("Could not get PID for PSN {0} {1}", psn.High, psn.Low)); this.outTail = outTail; this.errTail = errTail; }