Hi, Renato,

Check it out, I've changed this function:

==
public bool abrirSistema()
{
    Gtk.Timeout.Remove (Timer);
    Thread thread =
        new Thread(() => CarregarDados(lblDescricao));
    thread.Priority = ThreadPriority.Highest;
    thread.Start ();

    while (thread.IsAlive) {
        while (Application.EventsPending()) {
            Application.RunIteration ();
        }
    }

    if (!DadosCarregados) {
        Application.Quit ();
        System.Environment.Exit (0);
    } else {
        atualizaPelaHora ();
        Thread.Sleep (5000);
        VerificaCaixaAberto ();

    }

    return true;
}
==

The key here is that CarregarDados() does something, and modifies the
property "DadosCarregados" in order to know whether it succeded or not.
While the thread is doing all that loading from the database we do a busy
wait: while there are events pending, we run an iteration. This way the
interface responds to the user even while loading the data.

Still does not completely work since you do a lot of modification in the
interface in your CarregarDatos() function.

You have to separate all of that: make your loading functions
interface-agnostic, setting a dlag such as DadosCarregados, and then, in
the main thread (not in the created one), update the user interface.

Hope this helps.

-- Baltasar
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.dot.net
http://lists.dot.net/mailman/listinfo/gtk-sharp-list

Reply via email to