internal static void Init() { if (!ms_inited) { if (!ms_canInit) { throw new InvalidOperationException("mobjc was used, but CanInit is false"); } // This will force AppKit and Foundation to load if they have not already been loaded // (normally the static NSApplication ctor in mcocoa will take care of this, but some // apps may want to create NSObjects before that). Unused.Value = NSAvailableWindowDepths(); NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool")); DoInit(); // NSAutoreleasePool cannot be used within Posix threads unless Cocoa // is switched to "multithreading mode". We always have at least two // threads (the main thread and the finalizer thread) so we'll switch // to multithreading mode here. Selector selector = new Selector("foo"); NSObject thread = new Class("NSThread").Call("alloc").Call("initWithTarget:selector:object:", null, selector, null).To <NSObject>(); Unused.Value = thread.Call("start"); ms_inited = true; pool.release(); } }