Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Beep cut short???

May
12,846
164
Rex, I have a plugin ALERT which executes a command upon console output, waiting at least a specified time between alerts. It works well except when the command piped to it finishes quickly.

This happens in my plugin:

Code:
while ( ReadFile(hIn, inBuf, 16384, &dwRead, NULL) && dwRead != 0 )
{
    WriteFile(hOut, inBuf, dwRead, &dwRead, NULL);
    if ( (dwThisTime = GetTickCount()) > dwNextTime )
    {
        dwNextTime = dwThisTime + 1000 * dwWait;
        CreateThread(NULL, 0, CommandThread, pCommand, 0, NULL);
    }
}
The thread simply executes the command:

Code:
DWORD WINAPI CommandThread ( LPVOID pCommand )
{
    WCHAR    szCommand[4096];

    lstrcpy(szCommand, (WCHAR*) pCommand);

    Command((WCHAR*) szCommand, 0);

    return 0;
}
When I call it like this (5 is the minimum wait):

Code:
echo foo | alert 5 beep 440 3
the beep is cut short when the prompt reappears. I would have thought that impossible and it doesn't happen if I BEEP any of the system sounds. Can you tell me what's happening?
 
Never mind. I get it. The process running my plugin command (in a pipe) is exiting taking with it whatever notification might be in progress.
 
Back
Top