Re: Problem with Threading Concept



Hi Naveen,

up to now I have not heard of any problems compiling gtkdatabox on a
windows machine (I have never tried myself, though). My suggestion:

1) Compile gtk+ first and run a test program that comes with it.
2) Do the same with gtkdatabox.
3) Now try your own application.

1) and 2) should be rather easy, 3) depends on your code (platform
dependencies?).

When it comes to more specific problems with anything except the
gtkdatabox itself on windows, I will be of no help, though, since I do
practically everything on Linux.


Regards,

Roland

naveen wrote:
> Sir,
> 
> yes you are right some many people told me not to use
> gtk_main_iteration.
> 
> I should use gdk_threads_enter() and gdk_threads_leave (),
> only when i am using widgets in the main thread.Now solved
> my problem by the help gtk lists.
> 
> I have done my application using databox-0.7.0.0 in linux i want the
> same application to be run in windows. Please can you give me some tips
> how i can run in windows..
> 
> 
> Thanks and Regards,
> Naveen.
> 
> 
> On Thu, 2007-02-22 at 22:30, gtkdatabox-list-request gnome org wrote:Re:
>> Send gtkdatabox-list mailing list submissions to
>> 	gtkdatabox-list gnome org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> 	http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
>> or, via email, send a message with subject or body 'help' to
>> 	gtkdatabox-list-request gnome org
>>
>> You can reach the person managing the list at
>> 	gtkdatabox-list-owner gnome org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of gtkdatabox-list digest..."
>>
>>
>> Today's Topics:
>>
>>    1. Re: Problems with Threading Concept (Roland Bock)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Wed, 21 Feb 2007 19:30:00 +0100
>> From: Roland Bock <box2OO6 eudoxos de>
>> Subject: Re: Problems with Threading Concept
>> To: gtkdatabox <gtkdatabox-list gnome org>
>> Message-ID: <45DC8FA8 5030602 eudoxos de>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> Hi Naveen,
>>
>> when it comes to multi-threading, I have almost no experience at all. If
>> I read the code right, you have the main thread which creates a
>> secondary thread which does nothing but print statements and calling
>> gtk_main_iteration.
>>
>> I suspect that the delay is in the gtk_main_iteration. You could add
>> some print statements after that function call (I love debugging by
>> printf).
>>
>> To be honest, I don't consider it wise to have gtk_main_iteration being
>> called in the second thread when gtk_main is called in the first thread.
>> That sounds like trouble.
>>
>> If that does not help (quite likely), you should ask somebody with gtk
>> AND threading experience.
>>
>>
>> Regards,
>>
>> Roland
>>
>> naveen wrote:
>>> Hi all,
>>>
>>> I have GUI developed based on gtk+-2.2.0,
>>>
>>> 1) I have button to start some process (continuous).
>>> 2) I need to stop that process, when i click the same button.
>>>
>>> to do the above tasks i developed a small application using threading
>>> concepts...
>>>
>>> //////////////////////////////////////////////
>>> #include <gtk/gtk.h>
>>> #include "stdio.h"
>>> #include <pthread.h>
>>>
>>>  int flag=1,toggle=0;
>>>     int i=0;
>>>     pthread_t yes_tid; 
>>>
>>> void hello()
>>> {
>>>
>>>     while (flag)
>>>     {
>>>   gdk_threads_enter ();
>>>
>>>       printf ("%d %d\n",i++,flag);
>>>       if (gtk_events_pending())
>>>       gtk_main_iteration(); // Handle unprocessed GTK events
>>>
>>>   gdk_threads_leave ();
>>>     }
>>>
>>> }
>>>
>>> void hello_print( GtkWidget *widget,
>>>             gpointer   data )
>>> {  
>>>    if(toggle==0)
>>>     {
>>>      toggle=1;
>>>      flag=1;
>>>      pthread_create (&yes_tid, NULL,(void *)hello, NULL);
>>>     }
>>>     else
>>>     {
>>>      flag=0;
>>>      toggle=0;
>>>     }
>>>
>>> }
>>> int main(int   argc,
>>>           char *argv[] )
>>> {
>>>     
>>>     GtkWidget *window;
>>>     GtkWidget *button;
>>>     g_thread_init (NULL);
>>>     gdk_threads_init ();
>>>
>>>   gdk_threads_enter ();
>>>
>>>     gtk_init (&argc, &argv);
>>>     
>>>     /* create a new window */
>>>     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>>>     
>>>     g_signal_connect (G_OBJECT (window), "destroy",
>>> 		      G_CALLBACK (gtk_main_quit), NULL);
>>>     
>>>     gtk_container_set_border_width (GTK_CONTAINER (window), 100);
>>>     
>>>     button = gtk_button_new_with_label("click it");
>>>     
>>>     g_signal_connect (G_OBJECT (button), "clicked",
>>> 		      G_CALLBACK (hello_print), NULL);
>>>     
>>>     gtk_container_add (GTK_CONTAINER (window), button);
>>>     
>>>     gtk_widget_show (button);
>>>     gtk_widget_show (window);
>>>     
>>>     gtk_main ();
>>>
>>>    gdk_threads_leave ();
>>>
>>>     return 0;
>>> }
>>>
>>> //////////////////////////////////////////////////////
>>> But the problem here for me is, the stop is not happening immediatly
>>> after the click..
>>>
>>> Is there any mistake the way i am doning it ... or do i need to follow
>>> any other procedure for it.. please help me out...
>>>
>>> Regards,
>>> Naveen.
>>>
>>> _______________________________________________
>>> gtkdatabox-list mailing list
>>> gtkdatabox-list gnome org
>>> http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
>>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> gtkdatabox-list mailing list
>> gtkdatabox-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
>>
>>
>> End of gtkdatabox-list Digest, Vol 5, Issue 7
>> *********************************************
>>
> 
> _______________________________________________
> gtkdatabox-list mailing list
> gtkdatabox-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
> 




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