App is running in two terminal for tx/Rx mode , app is not exit when I hot the keystr

Dear all,
I want that app that runs n tx mode, send the first frame to driver upon the tx interrupt then req complete in dpc then it returns to app to send the next frame…

I have did the Linux driver where I have used wait/wake method, in ioctl side I were waited for tx interrupt when tx interrupt come means where I’m wake then it returns to app to send the next frame… so contioulsy it sending data upto keyboard hit.

  1. app will be run in two terminal tx/Rx mode

  2. when it run tx mode it will contioulsy send the frame to driver where it uses the overlapped and waited for signal using getoverlappedresult with bwait true. Completionthread runs infinitely and check for getoverlappedstatus with timeout infinite which is running in while loop.

  3. so application for tx mode whether it blocks tat means it not running and it not sending any frame to driver side it were blocked , if doesn’t block means it will be properly exit.

In driver side I have forward the request upon the tx interrupt I queued to dpc routine and where im retreiving the request and complete and also check for request upto no entries. In application i have used overlapped ,created the events and Embedded to it and passed to deviceiocontrol , called getoverlappedresult then wait for single object then reset event n return the value. Im app main thread where I’m calling the tx function where it does the debiceioctrol with overlapped call getoverlappedresult then wait for single object and also running the completion thread n does the getoverlappedstatus. When I hit the keyboard strokes using !kbhit infinitely calling tbis tx function in one terminal then other terminal I meal callingthe Rx function.

Pls suggest me how I can exit the application for tx mode which is running infinitely

>Pls suggest me how I can exit the application for tx mode which is running infinitely
// if set to 1, the thread must stop its job and exit.

LONG ExitFlag = 0;

DWORD ThreadAProc(LPVOID Param){
while(1){
// Perform the thread job

// check the exit flag on every loop
if(InterLockedAnd(&ExitFlag, 1) == 1 ){
// We’ve been asked to go…
break;
}
}
return 0;
}

DWORD ThreadB(LPVOID Param){
char c=0;

printf(“PRESS THE X KEY TO LEAVE …”);

while(1){
c = getchar();
if(c != ‘x’ && c != ‘X’){
continue;
}
//
// Ask ThreadA to leave with the ExitFlag
//
InterLockedOr(&ExitFlag, 1);

#define ONE_SECOND 1000
// Give ThreadA the time to notice the flag change and exit.
Sleep(ONE_SECOND);
break;
}

#define FIVE_SECONDS 5000

printf(“Giving ThreadA five seconds before forced termination…\n”);

if(WAIT_OBJECT_0 != WaitForSingleObject(ThreadA, FIVE_SECONDS)){
// Forced termination of the thread.
printf(“Warning, ThreadA isn’t responding, forcing termination…\n”);
assert(TerminateThread(ThreadA, (-1)));
}
return 0;
}

Please refer this link (http://www.osronline.com/showthread.cfm?link=280703)

Give me the suggestion