0

i develop a windows service, this service should write log in a text file (per 5 minutes), but it isn't wrote when the system go to sleep mode. why doesn't 'WriteLine()' function write in sleep mode? what do i do? i need logs in all of times in several days ... please help me.

nabegheh95
  • 195
  • 3
  • 19
  • 1
    Sleep mode is exactly that. The computer is all but shut down. There are no processes running, it just stores the state of the machine so that it can boot up where you left off. If you want a process to continue to run, put it on a machine that does the same. – crthompson Sep 15 '14 at 04:47
  • 4
    Because the CPU is sleeping and cannot do anything. Also why log something if nothing is happening? – leppie Sep 15 '14 at 04:47
  • 1
    can you do your work while sleeping? :) never let your pc sleep will solve your problem, keep it awake – ah_hau Sep 15 '14 at 05:34

1 Answers1

2

Sleep mode and hibernation both simply save the state your desktop is in (which programs open, files, etc.) in a file that is saved in RAM or on the hard drive respectively. But the computer is then put into a low power state. Nothing can actually run or do work in that state.

You can change power settings to never go to sleep (or hibernate) You also can prevent the system go to sleep via your code, see those links:

  1. How to prevent Windows from entering idle state?
  2. SetThreadExecutionState function
Community
  • 1
  • 1
AsfK
  • 3,328
  • 4
  • 36
  • 73