ProcessLink.cpp
// Join to the threads so that exiting won't crash.
Join to the threads so that exiting won't crash.
Join to the threads so that exiting won ' t crash .
ProcessLink::~ProcessLink(void)
{
    if (csInputHandle != nullptr)
    {
        CloseHandle(csInputHandle);
    }
    if (connectionThread.joinable())
    {
        connectionThread.join();
    }
    if (readThread.joinable())
    {
        readThread.join();
    }
    if (csOutputHandle != nullptr)
    {
        CloseHandle(csOutputHandle);
    }
    while (!receivedMessages.empty())
    {
        MessageData message = receivedMessages.top();
        receivedMessages.pop();
        delete [] message.messageData;
    }
}
ProcessLink :: ~ ProcessLink ( void ) { if ( csInputHandle != nullptr ) { CloseHandle ( csInputHandle ) ; } if ( connectionThread . joinable ( ) ) { connectionThread . join ( ) ; } if ( readThread . joinable ( ) ) { readThread . join ( ) ; } if ( csOutputHandle != nullptr ) { CloseHandle ( csOutputHandle ) ; } while ( ! receivedMessages . empty ( ) ) { MessageData message = receivedMessages . top ( ) ; receivedMessages . pop ( ) ; delete [ ] message . messageData ; } }
Join to the threads so that exiting won't crash.
Join to the threads so that exiting won ' t crash .
// This must be closed first so that the C# application's read thread terminates... // ... which allows our read thread to terminate in the join phase. // Delete all the message that haven't been read