Service doesn’t work after sleep

Home Forums Discussions Support Portal Service doesn’t work after sleep

This topic contains 4 replies, has 2 voices, and was last updated by  Vadim Smirnov 6 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5348

    couttsj
    Participant

    I designed a DNS monitor program in VB6 that has an active desktop component and a service component. The service component starts automatically and works in the background even when the user is logged off. I have tested it on windows XP, Vista, and 7 (all 32 bit), and although I am currently having some problems with 64 bit Win7, both programs work very well with the following exceptions.

    1. The service component stops working after the computer is revived from a sleep mode. As per the samples provided by NT Kernel Resources, the packet read routine is in a loop. I have the program logging whenever it enters and leaves that loop, and it does not exit the loop. I have no idea how to troubleshoot this problem. Any help would be appreciated.

    2. The logfile name uses the current date in the format “yymmdd.log”. This format is necessary to keep the file names in chronological order. On a Vista machine (and I presume Win7), the month and day get reversed using the service component in Session 0. The desktop component in Session 1 conforms to the specified format.
    12/06/10 03:16 PM 79 100612.log < ---- Service component
    12/06/10 03:16 PM 72 101206.log < ---- Desktop component
    I changed both programs to “yyyymmdd.log” with the same results. This is obviously an OS issue, but I got no help from Microsoft Technet.

    J.A. Coutts

    #7003

    couttsj
    Participant

    Second problem resolved. Changed:
    Filename = WinDir & “system32logfilesDNS” & Format(Date$, (“yyyymmdd”)) & “.log”
    to
    Filename = WinDir & “system32logfilesDNS” & Year(Now) & Month(Now) & Day(Now) & “.log”
    and month/day reversal when running the service disappeared.

    #7004

    couttsj
    Participant

    I put in an idle counter (Approx. 50 seconds) and logged the results to file. The counter was reset every time an Ethernet packet was received. What I discovered was that after a wake up from an S3 sleep mode, the “Do While ReadPacket(nHandle, Request)” never returned a true value, and the counter kept incrementing. Is there a work around available for this?

    #7005

    couttsj
    Participant

    All attempts to get the service to reactivate itself failed. All attempts to get the restart service option to do the job resulted in a hung service manager thread with a status of “Stopping”. In order to restart an application, I would normally pass control and a handle to a second program or script to kill the application, wait an appropriate period, restart the application, and then kill the second application itself. Being a service, this approach was not too appealing, but the following code did the job after it detected no ethernet traffic:
    Service1.Connect ‘This command stops the service?
    Shell (“net start ServiceName”) ‘This command starts the service!
    The System event log shows the service being stopped and then started with the same time stamp. 2 seconds later, my own log file shows the service actually being started. This is the first time I have ever got an application to restart itself, and I can’t explain how or why.

    #7006

    Vadim Smirnov
    Moderator

    In the sleep mode system may power down network interfaces thus changing the network adapters list. So in general after the system is back from the sleep mode you have to reinitialize adapters list and restart packet capturing using new adapter handles.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.