Example #1
0
    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);
        }
    }
Example #2
0
        public static void TestPid()
        {
            var psn = new ProcessSerialNumber(0, 2 /* kCurrentProcess */);
            int pid = ProcessManager.GetProcessPid(psn);

            Assert.AreNotEqual(-1, pid);
        }
Example #3
0
        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();
        }
Example #4
0
    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);
        }
    }
Example #5
0
 static extern int CPSSetProcessName(ref ProcessSerialNumber psn, string name);
Example #6
0
 static extern int GetCurrentProcess(out ProcessSerialNumber psn);
Example #7
0
 private static extern short SetFrontProcess(ref ProcessSerialNumber psn);
Example #8
0
 private static extern int TransformProcessType(ref ProcessSerialNumber psn, uint type);
Example #9
0
 private static extern int TransformProcessType(ref ProcessSerialNumber psn, uint type);
Example #10
0
 private static extern short SetFrontProcess(ref ProcessSerialNumber psn);
		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;
		}