Article View: borland.public.cppbuilder.nativeapi
Article #1313Re: Can't get the computer to programmatically wake from standby.... (original question in language cpp)
From: Wiljo
Date: Sat, 15 Sep 2007 18:08
Date: Sat, 15 Sep 2007 18:08
57 lines
3508 bytes
3508 bytes
Bob Gonder wrote:
> Wiljo wrote:
>
>> HANDLE hTimer = CreateWaitableTimer(NULL,TRUE,"VideoTimer");
>>
>> if( hTimer != NULL )
>> {
>> CancelWaitableTimer( hTimer );
>
> Redundant.
> SetWaitableTimer cancels the timer first.
I saw this in another example and I thought that too, but I figured that
it can't hurt, because I am setting the timer right thereafter.
>
>> if( SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, true ))
> To eliminate possible UTC problems, test with
> liDueTime.QuadPart=-200000000; // 20 seconds
> and see if it sleeps for 20 seconds.
I don't have UTC problems, because the thread I created uses the
WaitForSingleObject function, with the handle to that timer, followed by
an update of the caption of a panel on the main window at the correct
time. So the thread works, as long as I don't suspend my computer. The
signal of the waitable timer arrives at the correct time.
>> {
> Also, you should check this error as well....
> fResume
> [in] If this parameter is TRUE, restores a system in suspended power conservation mode
> when the timer state is set to signaled. Otherwise, the system is not restored. If the
> system does not support a restore, the call succeeds, but GetLastError returns
> ERROR_NOT_SUPPORTED.
I'll try this. I didn't know that. You would expect a function to return
TRUE on every success, not on half successes.
>
>> //* This executes a thread that uses
>> //* WaitForSingleObject( hTimer, 90000 );
>> mWaitingTest.mExecuteThread( new( HERE ) CWaitingThread( hTimer ));
>
> I don't think hTimer is valid in another thread.
> Your security attribute is set to "not-inheritable".
The handle is valid in another process, because my example works as long
as the computer is not sent to the suspended state before the timer signals.
>
>> //* Here I initiate the Standby mode
>> //* But when I enable this the computer does not wake at
>> //* the desired time of one minute
>> // SetSuspendState( FALSE, FALSE, FALSE );
>
> I think you should use a callback function in
> SetWaitableTimer. It would either finish the job of turning on
> the power, or just post a message for your app to start recording.
> It could also Delete the Timer so you could Create it the next time.
>
>
That is a good idea, and I will let you know if that does the trick.
Thanks,
Wiljo.
Technical Details
Message-ID:
<46ec1fd5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46eaf724$1@newsgroups.borland.com> <u47me3ltdcd2btvkn32ib000kv676ljiun@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,dbb9f35f467d4b41 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 15 Sep 2007 20:08:32 +0200 From: Wiljo <nospam@nospam.com> User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Can't get the computer to programmatically wake from standby.... (original question in language cpp) References: <46eaf724$1@newsgroups.borland.com> <u47me3ltdcd2btvkn32ib000kv676ljiun@4ax.com> In-Reply-To: <u47me3ltdcd2btvkn32ib000kv676ljiun@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 000774-7, 15-09-2007), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 81.207.96.243 Message-ID: <46ec1fd5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1189879765 81.207.96.243 (15 Sep 2007 11:09:25 -0700) Lines: 57 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail