标题:
我的Chess程序的出现的多线程的问题,请高手帮我看一下。万分感谢!
[打印本页]
作者:
技术
时间:
2009-4-24 22:13
标题:
我的Chess程序的出现的多线程的问题,请高手帮我看一下。万分感谢!
case WM_LBUTTONDOWN:
dx=LOWORD(lParam);
dy=HIWORD(lParam);
/*if(!UpBDN&&!DownBDN&&DNOne)
{
ENDP=true;
DNOne=false;
}*/
if(!UpBDN&&!DownBDN)
{
Over=false;
BPLANDOWN=true;
while(!VR&&!VB&&BREGRETDOWN)
{
if (TurnRGo)
{
if(ReturnCheck)
{
OutputPMove();
ReturnCheck=false;
}
// Start the child process.
CreateProcess( NULL, // No module name (use command line).
"JSearch.exe", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ); // Pointer to PROCESS_INFORMATION structure.
/*if(ENDP)
{
TerminateProcess(pi.hProcess,0);
ENDP=false;
UpBDN=true;
DownBDN=true;
break;
}
DNOne=true;*/
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
FIBManNMove=fopen("OUTBManNMOVE","rb");
fscanf(FIBManNMove,"CI=%d CJ=%d NI=%d NJ=%d",&BManMoveCI,&BManMoveCJ,&BManMoveNI,&BManMoveNJ);
fclose(FIBManNMove);
ScanUserTime();
RManUserTimeS+=INUserTime;
RManUT.Hour=int(RManUserTimeS/3600);
RManUT.Minute=int(RManUserTimeS/60)-60*RManUT.Hour;
RManUT.Second=RManUserTimeS-3600*RManUT.Hour-60*RManUT.Minute;
DelayTime=0;
if(RDown)
DNMoveRMan(BManMoveCI,11-BManMoveCJ,BManMoveNI,11-BManMoveNJ);
else if(BDown)
DNMoveRMan(BManMoveCI,BManMoveCJ,BManMoveNI,BManMoveNJ);
while(DelayTime<=685)
{
DelayTime++;
MyPaint(hdc);
}
DelayTime=0;
CONToChessBoard();
CheckR();
BManMoveCI=0;
BManMoveCJ=0;
BManMoveNI=0;
BManMoveNJ=0;
FIBManNMove=fopen("OUTBManNMOVE","wb");
fclose(FIBManNMove);
TurnRGo=false;
TurnBGo=true;
}
if (TurnBGo)
{
fclose(FOBManCMove);
if(ReturnCheck)
{
OutputPMove();
ReturnCheck=false;
}
// Start the child process.
CreateProcess( NULL, // No module name (use command line).
"JSearch.exe", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ); // Pointer to PROCESS_INFORMATION structure.
/*if(ENDP)
{
TerminateProcess(pi.hProcess,0);
ENDP=false;
UpBDN=true;
DownBDN=true;
break;
}
DNOne=true; */
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
FIBManNMove=fopen("OUTBManNMOVE","rb");
fscanf(FIBManNMove,"CI=%d CJ=%d NI=%d NJ=%d",&BManMoveCI,&BManMoveCJ,&BManMoveNI,&BManMoveNJ);
fclose(FIBManNMove);
ScanUserTime();
BManUserTimeS+=INUserTime;
BManUT.Hour=int(BManUserTimeS/3600);
BManUT.Minute=int(BManUserTimeS/60)-60*BManUT.Hour;
BManUT.Second=BManUserTimeS-3600*BManUT.Hour-60*BManUT.Minute;
DelayTime=0;
if(RDown)
DNMoveBMan(BManMoveCI,BManMoveCJ,BManMoveNI,BManMoveNJ);
else if(BDown)
DNMoveBMan(BManMoveCI,11-BManMoveCJ,BManMoveNI,11-BManMoveNJ);
while(DelayTime<=685)
{
DelayTime++;
MyPaint(hdc);
}
DelayTime=0;
CONToChessBoard();
CheckB();
BManMoveCI=0;
BManMoveCJ=0;
BManMoveNI=0;
BManMoveNJ=0;
FIBManNMove=fopen("OUTBManNMOVE","wb");
fclose(FIBManNMove);
TurnRGo=true;
TurnBGo=false;
}
}
}
break;
我是想在界面点击鼠标左键后中断JSearch线程,但是主程序不能接收鼠标的消息,一点鼠标就死机。请高手帮我解决,我万分感谢,也会帮帮忙解决我能解决的问题的。我是新来的,请多照顾。
欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/)
Powered by Discuz! 6.0.0