Skip to content

Instantly share code, notes, and snippets.

@jstedfast
Created November 20, 2012 17:11
Show Gist options
  • Save jstedfast/4119319 to your computer and use it in GitHub Desktop.
Save jstedfast/4119319 to your computer and use it in GitHub Desktop.
How to run a modal dialog & pump the main loop
IntPtr session = NSApplication.SharedApplication.BeginModalSession (window);
NSRunResponse result = NSRunResponse.Continues;
// Loop until some result other than continues:
while (result == NSRunResponse.Continues) {
using (var pool = new NSAutoreleasePool ()) {
// Run the window modally until there are no events to process:
result = (NSRunResponse) NSApplication.SharedApplication.RunModalSession (session);
// Give the main loop some time:
NSRunLoop.Current.LimitDateForMode (NSRunLoopMode.Default);
}
}
NSApplication.SharedApplication.EndModalSession (session);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment