Home > Back-end >  O solve ah ~ ~ ~ ~ ~ ~ which eldest brother help have a look at this program where we have a problem
O solve ah ~ ~ ~ ~ ~ ~ which eldest brother help have a look at this program where we have a problem

Time:10-09

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * thread creation * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

if(! SetCommMask (hCom, EV_RXCHAR))
{
AfxMessageBox (L "create mask failed");
}
HThreadEvent=CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) ThreadProcEven, & amp; DwParam, 0, & amp; DwThreadID);
If (hThreadEvent==INVALID_HANDLE_VALUE)
{
AfxMessageBox (L "event thread creation failed");
}
The else
{
FEventRun=true;
BlnOpened=true;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * thread function * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
DWORD ThreadProcEven (LPVOID pParam)
{
BYTE ah [20].
Cstrings myStr;
DWORD dwRead dwRes;
DWORD dwEvtMask, error;
While (fEventRun)
{
DwEvtMask=0;
Eol. HEvent=CreateEvent (NULL, true, false, NULL);//EOL OVERLAPPED structure is set to no signal
WaitCommEvent (hCom, & amp; DwEvtMask, & amp; Eol);//wait for the EOL into a signal
The switch (dwEvtMask)
{
Case EV_RXCHAR://when there is a character in the input buffer to perform a read operation
{
Rol. HEvent=CreateEvent (NULL, true, false, NULL);//set the ROl to no signal
If (Rol. HEvent==NULL)
{
AfxMessageBox (L "hEvent empty");
return -1;
}
If (ReadFile (hCom, & amp; Ah, 5, NULL, & amp; Rol))//read the data in the ah
{
if(! PurgeComm (hCom, PURGE_RXCLEAR))//clear input buffer
{
Error=GetLastError ();
MyStr. The Format (_T (" ERROR coed: [% d] "), the ERROR).
AfxMessageBox (myStr);//display an error message
}
AfxMessageBox (L "successfully read data 1");
}
The else
{
DwRes=WaitForSingleObject (Rol. HEvent, 5000);//waiting for the read operation is completed
The switch (dwRes)
{
Case WAIT_OBJECT_0:
{
AfxMessageBox (L "successful readout 2");
if(! PurgeComm (hCom, PURGE_RXCLEAR))
{
Error=GetLastError ();
MyStr. The Format (_T (" ERROR coed: [% d] "), the ERROR).
AfxMessageBox (myStr);
}
}
break;
Case WAIT_TIMEOUT:
{
AfxMessageBox (L "timeout");
break;
}
}
}
}
}
}
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */




/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * off thread * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

FEventRun=false;
The CloseHandle (hThreadEvent);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


When debugging computer kept crashing
360 the number has been risen debugging has been increased to 99% and then blue screen
What reason is this?????

CodePudding user response:

The while loop in memory leaks
  • Related