[Gtk-sharp-list] Error loading program

Baltasar GarcĂ­a Perez-Schofield baltasarq at gmail.com
Tue Jan 24 10:17:40 UTC 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/gtk-sharp-list/attachments/20170124/4271c725/attachment-0002.html>


More information about the Gtk-sharp-list mailing list