Click here to Skip to main content
15,890,506 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 22:39
_Flaviu20-Sep-15 22:39 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt20-Sep-15 22:51
professionalJochen Arndt20-Sep-15 22:51 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:04
_Flaviu20-Sep-15 23:04 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt20-Sep-15 23:14
professionalJochen Arndt20-Sep-15 23:14 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:14
_Flaviu20-Sep-15 23:14 
GeneralRe: Shift + VK_LEFT Pin
Jochen Arndt20-Sep-15 23:21
professionalJochen Arndt20-Sep-15 23:21 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:23
_Flaviu20-Sep-15 23:23 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu21-Sep-15 22:13
_Flaviu21-Sep-15 22:13 
AnswerRe: Shift + VK_LEFT Pin
Richard MacCutchan20-Sep-15 22:32
mveRichard MacCutchan20-Sep-15 22:32 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 22:53
_Flaviu20-Sep-15 22:53 
GeneralRe: Shift + VK_LEFT Pin
Richard MacCutchan20-Sep-15 23:05
mveRichard MacCutchan20-Sep-15 23:05 
GeneralRe: Shift + VK_LEFT Pin
_Flaviu20-Sep-15 23:15
_Flaviu20-Sep-15 23:15 
Question[SOLVED?] Using "this" pointer to "copy" pointer Pin
Vaclav_19-Sep-15 17:11
Vaclav_19-Sep-15 17:11 
AnswerRe: Using "this" pointer to "copy" pointer Pin
Richard MacCutchan19-Sep-15 21:10
mveRichard MacCutchan19-Sep-15 21:10 
GeneralRe: Using "this" pointer to "copy" pointer Pin
Vaclav_20-Sep-15 3:02
Vaclav_20-Sep-15 3:02 
GeneralRe: Using "this" pointer to "copy" pointer Pin
Richard MacCutchan20-Sep-15 6:42
mveRichard MacCutchan20-Sep-15 6:42 
AnswerRe: [SOLVED?] Using "this" pointer to "copy" pointer Pin
Richard MacCutchan20-Sep-15 6:52
mveRichard MacCutchan20-Sep-15 6:52 
QuestionHow to break an infinite loop Pin
Mohamed Nehad18-Sep-15 16:57
Mohamed Nehad18-Sep-15 16:57 
AnswerRe: How to break an infinite loop Pin
Richard MacCutchan18-Sep-15 21:43
mveRichard MacCutchan18-Sep-15 21:43 
AnswerRe: How to break an infinite loop Pin
Fuseteam19-Sep-15 8:36
Fuseteam19-Sep-15 8:36 
QuestionDefine 'Enter' key in C Pin
Mohamed Nehad18-Sep-15 16:52
Mohamed Nehad18-Sep-15 16:52 
QuestionRe: Define 'Enter' key in C Pin
Richard MacCutchan18-Sep-15 21:44
mveRichard MacCutchan18-Sep-15 21:44 
AnswerRe: Define 'Enter' key in C Pin
Mohamed Nehad20-Sep-15 12:04
Mohamed Nehad20-Sep-15 12:04 
QuestionCall to std::thread::join() in the destructor of a global variable Pin
dchabaud17-Sep-15 3:49
dchabaud17-Sep-15 3:49 
I have the following code and when running it stays blocked on the join(). So, is it possible to call std::thread::join() in the destructor of a global variable?

C#
void MyTimerFunction();

class MyGlobal
{
public:
    std::atomic<bool>   m_Flag;
    std::thread         m_GlobalThread;

    MyGlobal() {
        m_Flag = true;
        m_GlobalThread = std::thread(MyTimerFunction);
    }

    ~MyGlobal()
    {
        m_Flag = false;
        if (m_GlobalThread.joinable())
            m_GlobalThread.join();
        std::cout << "MyGlobal destroyed" << std::endl;
    }
};

MyGlobal Test;


void MyTimerFunction()
{
    do
    {
        std::this_thread::sleep_for(std::chrono::seconds{10});
        if (!Test.m_Flag)
            break;

        std::cout << "New tick" << std::endl;
    } while (true);

    std::cout << "Exit MyTimerFunction" << std::endl;
}




int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "Main thread sleeping..." << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds{15});
    std::cout << "Main thread awaking..." << std::endl;

    std::cout << "Main thread returning..." << std::endl;
    return 0;
}

AnswerRe: Call to std::thread::join() in the destructor of a global variable Pin
CPallini17-Sep-15 5:13
mveCPallini17-Sep-15 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.