473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Boost::Thread: Joining without waiting

Hi!
I'm experimenting with boost::thread. I have a GUI application with a
slot function:

void someFunction(){...}
void Frame::OnOkButtonClick(...)
{
switch(someInteger)
{
case 0: break
case 1:
{
boost::thread mthTread(&someFunction);
mthTread.join();
break;
}
default: break
}
}

The program compiles and runs properly, but the GUI doesn't react
(Well, this is what to expect with this code because it waits for the
Thread to finish).
How can I make the program not to wait until the thread is finished?
Thanks in advance!

Kind regards, Hans
Jan 31 '08 #1
2 3325
Hans Mull a écrit :
Hi!
I'm experimenting with boost::thread. I have a GUI application with a
slot function:

void someFunction(){...}
void Frame::OnOkButtonClick(...)
{
switch(someInteger)
{
case 0: break
case 1:
{
boost::thread mthTread(&someFunction);
mthTread.join();
break;
}
default: break
}
}

The program compiles and runs properly, but the GUI doesn't react
(Well, this is what to expect with this code because it waits for the
Thread to finish).
How can I make the program not to wait until the thread is finished?
Don't call join(). The thread will remain in detached state.

Michael
Jan 31 '08 #2
Michael DOUBEZ schrieb:
Hans Mull a écrit :
>Hi!
I'm experimenting with boost::thread. I have a GUI application with a
slot function:

void someFunction(){...}
void Frame::OnOkButtonClick(...)
{
switch(someInteger)
{
case 0: break
case 1:
{
boost::thread mthTread(&someFunction);
mthTread.join();
break;
}
default: break
}
}

The program compiles and runs properly, but the GUI doesn't react
(Well, this is what to expect with this code because it waits for the
Thread to finish).
How can I make the program not to wait until the thread is finished?

Don't call join(). The thread will remain in detached state.

Michael
Thar worked well, thank you!
Jan 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dingounan | last post by:
how to compile boost.thread,and set it? I have trouble. platform: windows XP compiler: Borland C++ Compiler 5.5.1 commandline tools thanks.
1
by: deluded.soul | last post by:
Hi everyone, I am trying to use the boost multithreading library. I am having a problem as the join() function for the thread never returns. I am using a boolean variable to indicate when the...
4
by: Lighter | last post by:
#include <boost/thread/thread.hpp> #include <iostream> using namespace std; using namespace boost; void hello() { cout << "Hello world, I'm a thread!" << endl; }
5
by: linyanhung | last post by:
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two thread process. The code is something like this: #include <boost/thread/thread.hpp> void fun1() { //do something
3
by: Gary Wessle | last post by:
#include <boost/thread/thread.hpp> #include <iostream> using namespace std; class waiter { public: waiter(); void waiting(); void preform();
4
by: Gary Wessle | last post by:
Hi given the Boost thread example here http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/example/thread.cpp the code below attempts to run the example thread while...
2
by: Chameleon | last post by:
Why this strange output? Why so many d'tor calls? The code: ---------------------------------------------------------- #include <cstdio> #include <boost/thread/thread.hpp> class A {
3
by: Lars Uffmann | last post by:
I have this wxWidgets OnButtonClick event handler, that apparently holds a lock on all widgets in my form, but this event handler is supposed to end a thread in the background - while that thread...
1
by: Boogie | last post by:
Hi, A specific problem arises when I try to use boost::thread 1.35.0 with Borland Turbo 2006. Code below compiles but when run it throws (in commented line - thread creation): "assertion...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.