|
|
| Author |
Message |
|
|
ramesh Familiar Face
Joined: 16 Nov 2006 Posts: 40
|
Posted: Mon Apr 02, 2007 1:24 pm Post subject: multi threading in gtk |
|
|
hi all
i tried like this
void
on_button1_clicked ()
{
write2();
pthread_t thread2;
char *message1 = (char*)msg;
int iret2;
iret2 = pthread_create( &thread2, NULL, *write1, (void*) message1);
}
void *write1(void *ptr)
{
char *msg1;
msg1 = (char *) ptr;
printf("%s",msg1);
}
void write2()
{
//here is my gtk apllication(gui)
it has a buton to invoke the perticular thread
}
it has some big code
so here i given it short.
first i ve to run my gtk application.
it has a buton.
when i click the button, some thread has to be invoked.
here my problem is
after clicking the button my gtk(gui) application is hanging up to compltetion of
write1 ();
so it is taking long time to come original state(gtk application)
what i would like to do is
first i have to open the window.
and clicking the buttion,
invoking the thread,
with out hanging the window.
how can i do this
can you provide some example..
please help me in this way
thank you in advance |
|
| Back to top |
|
 |
hydra Familiar Face
Joined: 23 Jan 2007 Posts: 35
|
Posted: Mon Apr 02, 2007 8:28 pm Post subject: |
|
|
Only one thread have to own the GUI control at a time. So, if you want to access GUI from several simultaneously running threads ..... you can not do that.
The main 2 ways to solve this is to use g_add_timeout () and g_thread_enter /g_thread_leave ()
And about the example... I have no such one now but tomorrow will check my sources..
Recently I found this site. http://www.gtk-server.org/index.html
This is Gtk server and it listenes for incomming connections on basic I/O files and pipes.
It is possible to write a Gtk application without to use C/C++ or any other programming language.. just write files, type commands and the application will be created. Cool!! |
|
| Back to top |
|
 |
ramesh Familiar Face
Joined: 16 Nov 2006 Posts: 40
|
Posted: Tue Apr 03, 2007 5:13 am Post subject: thank you for quick replay |
|
|
HI
ONETHING.
I AM NOT USING THREADS IN MAIN LOOP
MAIN();
I WOULD LIKE TO USE THREADS IN SOME OTHER FUNCTION WHERE I NEED.
CAN U PLEASE HELP ME IN THIS WAY
THANK YOU IN ADVANCE |
|
| Back to top |
|
 |
hydra Familiar Face
Joined: 23 Jan 2007 Posts: 35
|
|
| Back to top |
|
 |
|