[Gtk-sharp-list] How to implement a splash screen?

Christian Hoff christian_hoff at gmx.net
Mon Mar 30 09:39:58 EDT 2009


DarkPhoenix wrote:
> I want to do something similar to when MonoDevelop loads in my application;
> show a splash screen while the heavy duty loading takes place, and then show
> the main window. I have created a Gtk# project, with the standard
> initialization routine:
>
> public static void Main (string[] args)
> {
> 	Application.Init();
> 	MainWindow window = new MainWindow();
> 	window.Show();
> 	Application.Run();
> }
>   
You can use Gtk.Application.Invoke (some_method) and then call 
Aplication.Run:

public static void Main (string[] args)
{
	Application.Init();
	MainWindow window = new MainWindow();
	window.Show();
	Gtk.Application.Invoke (some_method);
	Application.Run();
}

public static void some_method (object sender, System.EventArgs e) {
             // This code is called from the Gtk+ main loop(which is run 
by calling Gtk.Application.Run ();
             Thread.CurrentThread.Sleep (5000);
             mywindow.Hide ();
}

Gtk.Application.Run does never return until Gtk.Application.Quit is 
called. It goes into an endless loop, the main loop. By using 
Application.Invoke, the main loop will call the specified method in one 
of its next iterations.

Christian



More information about the Gtk-sharp-list mailing list