Question : WaitForSingleObject() issue

I created 3 functions for setting up a timer.  Following are the steps:
job starts - call ThreadStartTime() to start the timer
job ends  - call ResetTimer() to stop the timer

However, I never receive WAIT_TIMOUT from WaitForSingleObject() so sending page is not triggered. Please advice what I did wrong.  Thanks

void ThreadStartTimer()
{
      if (!QueueUserWorkItem(&StartSCTimer, NULL, WT_EXECUTEDEFAULT))
      {
            DWORD dw = GetLastError();
            LOG_ERROR << "***Failed to spawn  a thread to start StartTimer with errorCode:" << dw << eol;
       }
}

static DWORD WINAPI StartSCTimer(void)
{
      try
      {
            HANDLE hevent = CreateEvent(NULL, FALSE, FALSE, myeventID);
            if (hevent != NULL)
            {
                 
                  unsigned long msec = 2*1000; // 2 secs
                  DWORD dw = WaitForSingleObject(hevent, msec);
                  if (dw == WAIT_TIMEOUT)
                  {
                        LOG_ERROR << "Receives times out" << eol;
                         // send page
                   }
                   else if (dw == WAIT_OBJECT_0)
                   {
                          LOG_ERROR << "Wait returns before times out" << eol;
                    }
                    else
                    {
            LOG_DEBUG << "Abort" << eol;                        
      }
                     CloseHandle(hevent);      
            }
      }
      catch(...)
      {
            LOG_DEBUG << "***Exception caught in _HandleEvent" << eol;
      }
      return 0;
}

void ResetSCTimer()
{
    HANDLE hevent = OpenEvent( EVENT_ALL_ACCESS, FALSE, myeventID);
    if (hevent != NULL)
    {
        LOG_DEBUG << "Reseting SC timer." << eol;
        SetEvent(hevent);
     }
}

Answer : WaitForSingleObject() issue

Get a public IP address,
Domain Management Control Panel Setup,
Register this IP address to your domain's www record.

Server Setup:
Assign this IP to your server. C
Configure default website of the server.
Set the access settings to "anonymous" using website properties.

Firewall Settings:
Configure your firewall to allow the webserver IP address for port 80,8080 or 443 if your configure on SSL as well.
Random Solutions  
 
programming4us programming4us