|
-
April 2nd, 2013, 03:16 AM
#7
Re: Can local variable be passed as parameter into a new thread?
 Originally Posted by forester
Can local variable be passed as the parameter for a new created thread procedure?
This is easy with modern C++.
(Edit: code is incorrect, see post # 12)
Code:
#include <thread>
void CDLG::some_function()
{
CString strFileName="abc.doc";
std::thread(std::bind(ProcessContentThreadFunction, strFileName));
}
void ProcessContentThreadFunction(CString fileName)
{
// process the file
}
If your compiler doesn't support std::thread, you can use boost::thread instead.
Last edited by D_Drmmr; April 4th, 2013 at 03:21 AM.
Reason: added note
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|