Re: time consuming function/loop



thank you for the useful information, is there a way i
can give user an option to break the thread, like
cancel button.

--- "Brian J. Tarricone" <bjt23 cornell edu> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yogesh M wrote:
One of the function take long time and blocks
gtk_main. I dont want to put it in thread because it
contains some part of the code which draws[drawing
is not allowed in thread]. is there any way i can
make user to interrupt the thread and break it.

You have three options:

1) Use a separate thread, and communicate with the
main thread with a
GAsyncQueue, and continue to do drawing in the main
thread.

2) Initialise the glib/gdk thread systems before
calling gtk_init(), do
your processing in another thread, and surround
calls to gtk/gdk with
gdk_threads_enter() and gdk_threads_leave()

3) Keep it the way you have now, but do:
while(gtk_events_pending())
    gtk_main_iteration();
every now and then to process events and redraw
windows as needed.

The API docs and tutorials will be helpful in the
former two cases.

      -brian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)


iD8DBQFC8kuH6XyW6VEeAnsRAjhBAJ9kZiinHh1FVeYseWCZ4tPfdJPGWACgpCST
12hLqX2uy1gxKKID3W+0HCA=
=xR1J
-----END PGP SIGNATURE-----
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]