Automatic OS suspend-resume loop

  • Thread starter Thread starter MD
  • Start date Start date
M

MD

Hi
I'm porting a piece of code from C++ to C#.
This code makes automatic suspend and resume of OS in a loop (N times),
i.e. that the application N times does something, then suspends OS,
after OS resume (NOT manual, but from the timer) it returns to the
beginning of the loop etc.
In C++ the flow looks like this:
for (...)
{
// do something

CreateWaitableTimer (...)
SetWaitableTimer (...) // The last parameter (fResume) is true
SetSuspendState (...)
}



I know to make suspend in C#. The problem is with timer. How to do the
same in C#?

Thanks in advance!
 
Since you're converting the code, maybe you should use an Event to trigger
this thread to resume.
Polling is one way, but being event driven is a better way since a process
doesn't use any CPU until it's told to resume, which at that point it has
something to do.
 
Back
Top