473,288 Members | 1,743 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,288 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 3321
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.