GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 3:55 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: gdk_threads_enter / leave make my code slowly
PostPosted: Fri Aug 10, 2012 6:35 pm 
Offline

Joined: Fri Aug 10, 2012 6:21 pm
Posts: 2
Hello everybody this's my first post on this forum

I would ask about gdk_threads_enter / leave
When i use it my operation be very slowly
I have code for recursive search files
And i run it on the thread but when use
gdk_threads_enter / leave my operation be slowly
What should i do to update gui of my thread
Note : my code on thread call it self (Recursive)

And thanks for all


Top
 Profile  
 
 Post subject: Re: gdk_threads_enter / leave make my code slowly
PostPosted: Fri Aug 10, 2012 7:25 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the GTK+ forums.

General rule when it comes to threads and GTK+ is to use GTK+ from single thread only. This will reduce the amount of locks to the minimum and speed-up your code. If you have a long-running task in a thread, schedule GUI updates using g_idle_add() function, which is thread-safe and will run your update routine in GTK+ thread.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: gdk_threads_enter / leave make my code slowly
PostPosted: Fri Aug 10, 2012 7:47 pm 
Offline

Joined: Fri Aug 10, 2012 6:21 pm
Posts: 2
Thanks dear

Shortly before before your reply
I've found mistake on my code
I've added (g_thread_init(NULL); gdk_threads_init();) just to my code
And now work correctly with good speed

But i have other question
Is my way safely and good on my thread

Thank you once again


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group