Hi.

I'm having an issue with Gtk#. It's probably just through my own
incompetence.

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();
}

My problem is that before Application.Run(), nothing will show in Gtk, so I
can't do a splash screen and loading before it.

I tried this as a test:

public static void Main (string[] args)
{
        Application.Init();
        
        SplashScreen splash = new SplashScreen();
        splash.Show();
        
        // Pretend we're doing some heavy work...
        System.Threading.Thread.Sleep(5000);
        
        splash.Hide();
        splash = null;
        
        MainWindow window = new MainWindow();
        window.Show();
        Application.Run();
}

And of course it didn't work, it stalled for five seconds and then the main
window showed.

I tried placing the Application.Run() right after splash.Show(). Not a very
bright idea either; the code stopped executing there, the splash window
never got hidden, and the main window never got shown.

I even tried running the code on a separate thread, which wasn't much help
either; nothing ended up getting shown:

public static void ThreadSplash()
{
        SplashScreen splash = new SplashScreen();
        splash.Show();
        
        System.Threading.Thread.Sleep(5000);
        splash.Hide();
        splash = null;
        
        MainWindow window = new MainWindow();
        window.Show();
}

public static void Main (string[] args)
{
        Application.Init();
        
        Thread t = new Thread(ThreadSplash);
        t.Start();
        
        Application.Run();
}

This would all work out if I could figure out a way to run code after
Application.Run() without requiring any user input. Which I've been
unsuccessful at so far. That is why I'm here. I am hoping that one of you on
this forum can help me solve this problem.
-- 
View this message in context: 
http://www.nabble.com/How-to-implement-a-splash-screen--tp22757836p22757836.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to