pub fn run_context<F, R>(user_task: F) -> !where
    F: FnOnce() -> R + Send + 'static,
    R: Termination,
Expand description

Initialize and run the global context and spawn a user task in a new thread.

This function never returns. Once the user task finishes, the program exits with status code 0. Any background threads spawned by show-image will be joined before the process exits. It is the responsibility of the user code to join any manually spawned tasks.

The user task can call the context() function to obtain a ContextProxy, or the create_window() function to create a new window directly.

If the macros feature is enabled, you can also wrap your main function with the main macro instead of manually calling this function.

It is also possible to run a user task in the same thread as the context. See run_context_with_local_task() for more details.

Panics

This function panics if initialization of the global context fails. See try_run_context for a variant that allows the user task to handle these initialization errors.

This function also panics if it is called from any thread other than the main thread. Some platforms like OS X require all GUI code to run in the main thread. To ensure portability, this restriction is also enforced on other platforms.