<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wie wartet man richtig?]]></title><description><![CDATA[<p>Eigentlich ist mein Problem recht simpel:<br />
Mein Programm soll eine Aktion einmal pro Stunde ausführen und ich frage mich, wie man in der Zwischenzweit warten soll. Einfach mit Sleep(Ex) oder gibt es vielleicht eine bessere Möglichkeit? Hauptsache ist, dass so wenig Ressourcen wie möglich verbraucht werden. Optimal wäre es noch, wenn man das Programm/den Thread aus der Wartephase &quot;aufwecken&quot; könnte.</p>
<p>Vielen Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/215111/wie-wartet-man-richtig</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 23:09:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/215111.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Jun 2008 14:23:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie wartet man richtig? on Fri, 06 Jun 2008 14:23:08 GMT]]></title><description><![CDATA[<p>Eigentlich ist mein Problem recht simpel:<br />
Mein Programm soll eine Aktion einmal pro Stunde ausführen und ich frage mich, wie man in der Zwischenzweit warten soll. Einfach mit Sleep(Ex) oder gibt es vielleicht eine bessere Möglichkeit? Hauptsache ist, dass so wenig Ressourcen wie möglich verbraucht werden. Optimal wäre es noch, wenn man das Programm/den Thread aus der Wartephase &quot;aufwecken&quot; könnte.</p>
<p>Vielen Dank im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524122</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524122</guid><dc:creator><![CDATA[Der Schläfer]]></dc:creator><pubDate>Fri, 06 Jun 2008 14:23:08 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Fri, 06 Jun 2008 15:33:29 GMT]]></title><description><![CDATA[<p>Timer</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524168</guid><dc:creator><![CDATA[ceplusplus*loggedoff]]></dc:creator><pubDate>Fri, 06 Jun 2008 15:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Fri, 06 Jun 2008 15:47:37 GMT]]></title><description><![CDATA[<p>CreateWaitableTimer</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524182</guid><dc:creator><![CDATA[Dipl.Inf.Student]]></dc:creator><pubDate>Fri, 06 Jun 2008 15:47:37 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 09:39:59 GMT]]></title><description><![CDATA[<p>Ah ja, sehr gut! Genau sowas habe ich gesucht.<br />
Vielen Dank! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524551</guid><dc:creator><![CDATA[Der Schläfer]]></dc:creator><pubDate>Sat, 07 Jun 2008 09:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 10:28:33 GMT]]></title><description><![CDATA[<p>Eine Frage habe ich noch:<br />
Da mein Programm jede Stunde reagieren soll, muss natürlich auch beachtet werden, wenn ein neuer Tag beginnt. Also habe ich einfach in SYSTEMTIME zum Wert wHour eins dazu gezählt und wDay ebenfalls um 1 erhöht, wenn die Stundenzahl 23 überschritten hat.<br />
Was ist aber, wenn ein Monatsende erreicht wird? Dann muss ich ja irgendwie rausfinden, wie viele Tage der Monat hat, denn wenn die Zeit falsch gesetzt ist, reagiert der Timer nie und wartet ewig.<br />
Am besten wäre es natürlich, wenn man SetWaitableTimer dazu bringen könnte, nur den Wert wHour in der SYSTEMTIME Struktur zu beachten. Geht das irgendwie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524571</guid><dc:creator><![CDATA[Der Schläfer]]></dc:creator><pubDate>Sat, 07 Jun 2008 10:28:33 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 10:34:07 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">LARGE_INTEGER li;
li.QuadPart = static_cast&lt;__int64&gt;(-10000) * static_cast&lt;__int64&gt;(1000 * 60 * 60);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1524573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524573</guid><dc:creator><![CDATA[..........]]></dc:creator><pubDate>Sat, 07 Jun 2008 10:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 10:34:26 GMT]]></title><description><![CDATA[<p>nimm' 'nen richtigen Timer ... da ersparst du dir den ganzen Mist ..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524574</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524574</guid><dc:creator><![CDATA[dust]]></dc:creator><pubDate>Sat, 07 Jun 2008 10:34:26 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 10:42:26 GMT]]></title><description><![CDATA[<p>warum nimmst du nicht einfach Sleep??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524576</guid><dc:creator><![CDATA[hmmmmmmmm]]></dc:creator><pubDate>Sat, 07 Jun 2008 10:42:26 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 11:21:59 GMT]]></title><description><![CDATA[<p>hmmmmmmmm schrieb:</p>
<blockquote>
<p>warum nimmst du nicht einfach Sleep??</p>
</blockquote>
<p>Erscheint mir auch am einfachsten.</p>
<pre><code class="language-cpp">// Ungefähr so
enum WaitResult
{
	TIMEOUT,
	EVENT_SIGNALED
};

WaitResult WaitForFullHour()
{
	SYSTEMTIME t;
	GetSystemTime( &amp;t );
	WORD seconds_to_wait = (59-t.wMinute)*60  + (59-t.wSecond);
	Sleep( seconds_to_wait * 1000 );
	// bzw.
	if ( WAIT_TIMEOUT == WaitForSingleObject( event, seconds_to_wait*1000 ) )
		return TIMEOUT;
	return EVENT_SIGNALED;
}
</code></pre>
<p>edit: WaitForSingleObject eingebaut</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524589</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 07 Jun 2008 11:21:59 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 11:15:48 GMT]]></title><description><![CDATA[<p>Sleep ist nicht zu empfehlen, da damit auf kein Abbruch Signal mehr gewartet werden kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524590</guid><dc:creator><![CDATA[Nein!]]></dc:creator><pubDate>Sat, 07 Jun 2008 11:15:48 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sat, 07 Jun 2008 11:18:27 GMT]]></title><description><![CDATA[<p>Dann WaitForSingleObject</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1524591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1524591</guid><dc:creator><![CDATA[Ja!]]></dc:creator><pubDate>Sat, 07 Jun 2008 11:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to Wie wartet man richtig? on Sun, 08 Jun 2008 10:55:54 GMT]]></title><description><![CDATA[<p>Waitable Timer sind eigentlich genau das, was ich mir vorgestellt habe, da das Warten gegebenenfalls unterbrochen werden muss.<br />
Ich werden also einfach die Differenz zwischen der Systemzeit und der nächsten vollen Stunde berechnen und in Nanosekunden konvertieren.</p>
<p>Danke für eure Hilfe und die vielen Antworten. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1525040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1525040</guid><dc:creator><![CDATA[Der Schläfer]]></dc:creator><pubDate>Sun, 08 Jun 2008 10:55:54 GMT</pubDate></item></channel></rss>