PC Review


Reply
Thread Tools Rate Thread

Automatic OS suspend-resume loop

 
 
MD
Guest
Posts: n/a
 
      28th Sep 2005
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!

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJlbmRhbiBHcmFudA==?=
Guest
Posts: n/a
 
      28th Sep 2005
I see no reason you couldn’t use the exact same functions, all you need to do
is P/Invoke them.

CreateWaitableTimer:
http://pinvoke.net/default.aspx/kern...eWaitableTimer
SetWaitableTimer: http://pinvoke.net/default.aspx/kern...tWaitableTimer
SetSuspendState: http://pinvoke.net/default.aspx/powr...pendState.html

Brendan


"MD" wrote:

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

 
Reply With Quote
 
gabe garza
Guest
Posts: n/a
 
      28th Sep 2005
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.


"MD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to suspend or resume a process? YXQ Microsoft VB .NET 3 2nd Nov 2008 07:08 AM
Vista suspend/resume Andreas Y. Windows Vista General Discussion 3 13th Sep 2007 06:06 AM
Suspend To Resume Johns Microsoft Windows 2000 Networking 1 15th Jan 2005 02:17 PM
USB suspend/resume Dan Windows XP Hardware 1 15th Jul 2004 03:12 AM
Suspend and resume layout Brian Henry Microsoft VB .NET 4 3rd Jun 2004 12:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 PM.