<?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[Multithreading? (Semaphoren)]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe 2 Threads die eine Variable inkrementieren und dekrementieren. Das Problem ist das beide Threads eine Message mit PosteMessage schicken und dann UpdateData ausführen das diese Zahlen auf dem Dialog angezigt werden. Ich will nun sicherstellen das wenn der eine Thread das Zeug updatet der andere kein Zugriff darauf hat. Ich nehme an man macht dies mit CSemaphoren?! Nur erstelle ich solch ein Objekt mir CreateSemaphore und bekomme einen HANDLE darauf zurück aber was muss ich mit diesem machen?</p>
<p>MfG Mijenix</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/65213/multithreading-semaphoren</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 06:31:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/65213.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Feb 2004 17:04:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Multithreading? (Semaphoren) on Tue, 17 Feb 2004 17:04:49 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ich habe 2 Threads die eine Variable inkrementieren und dekrementieren. Das Problem ist das beide Threads eine Message mit PosteMessage schicken und dann UpdateData ausführen das diese Zahlen auf dem Dialog angezigt werden. Ich will nun sicherstellen das wenn der eine Thread das Zeug updatet der andere kein Zugriff darauf hat. Ich nehme an man macht dies mit CSemaphoren?! Nur erstelle ich solch ein Objekt mir CreateSemaphore und bekomme einen HANDLE darauf zurück aber was muss ich mit diesem machen?</p>
<p>MfG Mijenix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/461374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461374</guid><dc:creator><![CDATA[Mijenix]]></dc:creator><pubDate>Tue, 17 Feb 2004 17:04:49 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading? (Semaphoren) on Tue, 17 Feb 2004 19:28:45 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>folgender Hinweis aus der Msdn:</p>
<blockquote>
<p>Um zu ermitteln, welche Synchronisierungsklassen verwendet werden sollen, stellen Sie sich die folgenden Fragen:</p>
<p>1)Muß die Anwendung auf einen bestimmten Vorgang warten, bevor sie auf die Ressource zugreifen kann? (Beispiel: Daten müssen von einer Kommunikationsschnittstelle empfangen werden, bevor diese in eine Datei geschrieben werden können.)<br />
Verwenden Sie CEvent, falls die Antwort &quot;Ja&quot; lautet.</p>
<p>2)Können mehre Threads innerhalb derselben Anwendung auf diese Ressource gleichzeitig zugreifen? (Beispiel: Ihre Anwendung unterstützt bis zu fünf Fenstern mit Ansichten desselben Dokuments.)<br />
Verwenden Sie CSemaphore, falls die Antwort &quot;Ja&quot; lautet.</p>
<p>3)Können mehrere Anwendungen diese Ressource verwenden? (Beispiel: Die Ressource ist in einer DLL.)<br />
Verwenden Sie CMutex, falls die Antwort &quot;Ja&quot; lautet.</p>
<p>4)Verwenden Sie CCriticalSection, falls die Antwort &quot;Nein&quot; lautet.</p>
</blockquote>
<p>Verwende deshalb besser CEvent:</p>
<blockquote>
<p>CEvent objects have two types: manual and automatic. A manual CEvent object stays in the state set by SetEvent or ResetEvent until the other function is called. An automatic CEvent object automatically returns to a nonsignaled (unavailable) state after at least one thread is released.</p>
<p>To use a CEvent object, construct the CEvent object when it is needed. Specify the name of the event you wish to wait on, and that your application should initially own it. You can then access the event when the constructor returns. Call SetEvent to signal (make available) the event object and then call Unlock when you are done accessing the controlled resource.</p>
<p>An alternative method for using CEvent objects is to add a variable of type CEvent as a data member to the class you wish to control. During construction of the controlled object, call the constructor of the CEvent data member specifying if the event is initially signaled, the type of event object you want, the name of the event (if it will be used across process boundaries), and desired security attributes.</p>
</blockquote>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/461519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/461519</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Tue, 17 Feb 2004 19:28:45 GMT</pubDate></item></channel></rss>