Click here to Skip to main content
15,917,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionThreads Pin
Eytukan12-Sep-05 4:50
Eytukan12-Sep-05 4:50 
AnswerRe: Threads Pin
John M. Drescher12-Sep-05 5:52
John M. Drescher12-Sep-05 5:52 
GeneralRe: Threads Pin
Eytukan12-Sep-05 7:59
Eytukan12-Sep-05 7:59 
GeneralRe: Threads Pin
John M. Drescher12-Sep-05 8:03
John M. Drescher12-Sep-05 8:03 
Generalcode Pin
Eytukan12-Sep-05 8:15
Eytukan12-Sep-05 8:15 
AnswerRe: Threads Pin
David Crow12-Sep-05 6:25
David Crow12-Sep-05 6:25 
GeneralRe: Threads Pin
Eytukan12-Sep-05 8:10
Eytukan12-Sep-05 8:10 
GeneralRe: Threads Pin
Bob Stanneveld12-Sep-05 8:44
Bob Stanneveld12-Sep-05 8:44 
Hello,

If I see correct, you have a global instance of a char array. I guess that you use that array to write "TEST" and "CODE" to, that are passed to the thread.

Your problem is that you overwrite the contents of the array. So both threads are printing the same array!

To solve this problem, allocate a char array on the heap and pass that to the threads:
UINT CQACDDlg::DevMonitoring(LPVOID p)
{
    CQACDDlg * me = (CQACDDlg *)p;
    char* psAg = new char[/*length of string*/];
    // copy string contents to psAg
    me->DevMonitoring(psAg);
    return 0;
}

void CQACDDlg::DevMonitoring(char* pszAgeID)
{
    while(1)
        AfxMessageBox(ageID);
    delete[] pszAgeID;
}


Behind every great black man...
            ... is the police. - Conspiracy brother


Blog[^]
GeneralRe: Threads Pin
Eytukan12-Sep-05 22:20
Eytukan12-Sep-05 22:20 
GeneralRe: Threads Pin
Bob Stanneveld13-Sep-05 1:25
Bob Stanneveld13-Sep-05 1:25 
GeneralRe: Threads Pin
David Crow12-Sep-05 8:55
David Crow12-Sep-05 8:55 
GeneralRe: Threads Pin
Eytukan12-Sep-05 22:27
Eytukan12-Sep-05 22:27 
Questiondelete always goes with set NULL? Pin
valerie9912-Sep-05 3:49
valerie9912-Sep-05 3:49 
AnswerRe: delete always goes with set NULL? Pin
toxcct12-Sep-05 4:00
toxcct12-Sep-05 4:00 
AnswerRe: delete always goes with set NULL? Pin
David Crow12-Sep-05 4:28
David Crow12-Sep-05 4:28 
AnswerRe: delete always goes with set NULL? Pin
Nemanja Trifunovic12-Sep-05 4:28
Nemanja Trifunovic12-Sep-05 4:28 
AnswerRe: delete always goes with set NULL? Pin
S. Senthil Kumar12-Sep-05 4:42
S. Senthil Kumar12-Sep-05 4:42 
QuestionCOleDateTime question Pin
eli1502197912-Sep-05 3:47
eli1502197912-Sep-05 3:47 
AnswerRe: COleDateTime question Pin
David Crow12-Sep-05 4:28
David Crow12-Sep-05 4:28 
GeneralRe: COleDateTime question Pin
eli1502197912-Sep-05 4:34
eli1502197912-Sep-05 4:34 
GeneralRe: COleDateTime question Pin
David Crow12-Sep-05 4:45
David Crow12-Sep-05 4:45 
GeneralRe: COleDateTime question Pin
eli1502197912-Sep-05 20:34
eli1502197912-Sep-05 20:34 
GeneralRe: COleDateTime question Pin
David Crow13-Sep-05 2:08
David Crow13-Sep-05 2:08 
QuestionThread in VC++ ! Pin
lucdt12-Sep-05 3:08
lucdt12-Sep-05 3:08 
AnswerRe: Thread in VC++ ! Pin
Niklas L12-Sep-05 3:18
Niklas L12-Sep-05 3:18 

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.