|
A.cpp
.......생략
extern LPCSTR ksv;
..main(){
gwTest.Execute();
gwTest.HACC();
CString dis;
while(true){
::Sleep( 500 ) ;
dis = getchar();
if (dis == "1"){
ksv =_T("BB");
bThreadEixt = true;
gwTest.sfss();
}
::Sleep( 500 ) ;
if (dis == "2"){
ksv =_T("AA");
bThreadEixt =true;
gwTest.sfss();
}
}
B.cpp
LPCSTR ksv; 전역
void GWTest::HACC(){
USES_CONVERSION;
HANDLE hThread;
DWORD dwThreadID= 1;
hThread =CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)Command1,NULL, 0, &dwThreadID);
}
bool GWTest::sfss()
{
::Sleep( 500) ;
ResumeThread( hThread );
cout << ksv << endl;
printf(" 재개");
return true;
}
bool GWTest::stop(){
::Sleep( 500 ) ;
SuspendThread(hThread);
cout << ksv << endl;
printf(" 정지");
return true;
}
UINT GWTest::Command1(LPVOID lpv){
USES_CONVERSION;
while(true){
if (ksv != NULL){
printf("호출");
break;
}
}
return 0; <- 디버거로 가면 여기서 에러가 나옵니다.
}
첫 번째는 잘 됩니다.
두번째 값 부터는 동작을 안합니다.
변수값만 변경해서 재가동을 하는건데 원인을 잘 모르겠습니다.변수 선언이 잘못 되었는지..
|