Automatic OS suspend-resume loop

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!
 
G

gabe garza

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top