<?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[CCriticalSection]]></title><description><![CDATA[<p>Hallo<br />
ich versuche CriticalSection in meinen Threads anzuwenden.<br />
Doch klappt es nicht, denn die Threads benutzen die Funktion immer noch alle gleichzeitig.<br />
Hier ein wenig Code damit ihr seht was ich gemacht habe.</p>
<p>Thread erstellen:</p>
<pre><code>CMyThread *mMyThread; 

    mMyThread= (CMyThread *) AfxBeginThread(RUNTIME_CLASS(CMyThread), NULL, 0, CREATE_SUSPENDED); 
// Pointer usw.
mMyThread-&gt;ResumeThread();
</code></pre>
<p>Thread code:</p>
<pre><code>BOOL CMyThread::InitInstance()
{	

	criticalSection.Lock();

	pView-&gt;Test();

	criticalSection.Unlock();
}
</code></pre>
<p>In der Test Funktion wird eine MessageBox aufgerufen und danach eine unendliche Schliefe, sodass der Thread in ihr gefangen ist.<br />
Doch trotzdem wird die MessageBox in der Funktion mit jedem neuen Thread wieder ausgeführt. Doch theoretisch dürfte kein Thread in die Funktion mehr gelangen da ein Thread mit Hilfe der unendlichen Schleife gefangen ist oder?</p>
<pre><code>::MessageBox(hWnd,&quot;Thread aktivieren1.&quot;,&quot;Test&quot;, MB_OK);
	while(1)
		;
</code></pre>
<p>Wo liegt mein Fehler und was muss ich machen damit es funktioniert.<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152297/ccriticalsection</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Jul 2026 09:43:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152297.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jul 2006 08:59:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 08:59:13 GMT]]></title><description><![CDATA[<p>Hallo<br />
ich versuche CriticalSection in meinen Threads anzuwenden.<br />
Doch klappt es nicht, denn die Threads benutzen die Funktion immer noch alle gleichzeitig.<br />
Hier ein wenig Code damit ihr seht was ich gemacht habe.</p>
<p>Thread erstellen:</p>
<pre><code>CMyThread *mMyThread; 

    mMyThread= (CMyThread *) AfxBeginThread(RUNTIME_CLASS(CMyThread), NULL, 0, CREATE_SUSPENDED); 
// Pointer usw.
mMyThread-&gt;ResumeThread();
</code></pre>
<p>Thread code:</p>
<pre><code>BOOL CMyThread::InitInstance()
{	

	criticalSection.Lock();

	pView-&gt;Test();

	criticalSection.Unlock();
}
</code></pre>
<p>In der Test Funktion wird eine MessageBox aufgerufen und danach eine unendliche Schliefe, sodass der Thread in ihr gefangen ist.<br />
Doch trotzdem wird die MessageBox in der Funktion mit jedem neuen Thread wieder ausgeführt. Doch theoretisch dürfte kein Thread in die Funktion mehr gelangen da ein Thread mit Hilfe der unendlichen Schleife gefangen ist oder?</p>
<pre><code>::MessageBox(hWnd,&quot;Thread aktivieren1.&quot;,&quot;Test&quot;, MB_OK);
	while(1)
		;
</code></pre>
<p>Wo liegt mein Fehler und was muss ich machen damit es funktioniert.<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091611</guid><dc:creator><![CDATA[Thread]]></dc:creator><pubDate>Wed, 05 Jul 2006 08:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 09:01:19 GMT]]></title><description><![CDATA[<p>Wo hast du denn deine CriticalSection angelegt? Vor allem bist du dir ganz sicher, daß jeder Thread das selbe Objekt verwendet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091614</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 05 Jul 2006 09:01:19 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 09:10:46 GMT]]></title><description><![CDATA[<p>Also ich habe einfach eine Varibale in CMyThread deklariert und zwar wie folgt:</p>
<pre><code>private:
CCriticalSection criticalSection;
</code></pre>
<p>Zu dem zweiten Teil deiner Frage bin ich jetzt ein wenig überfragt.<br />
Wie kann ich das herausfinden?<br />
Wäre das bei dem Code (den ich gepostet habe) der Fall?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091623</guid><dc:creator><![CDATA[Thread]]></dc:creator><pubDate>Wed, 05 Jul 2006 09:10:46 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 09:12:45 GMT]]></title><description><![CDATA[<p>Thread schrieb:</p>
<blockquote>
<p>Also ich habe einfach eine Varibale in CMyThread deklariert</p>
</blockquote>
<p>Dann hat jeder Thread seine eigene Critical Section. Die blocken sich nicht gegenseitig. Du brauchst eine für alle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091624</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 05 Jul 2006 09:12:45 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 09:17:14 GMT]]></title><description><![CDATA[<p>Hört sich super an.<br />
Jetzt wäre es super wenn ihr mir noch eben zeigt wie ich folgendes hinbekomme:</p>
<blockquote>
<p>Du brauchst eine für alle</p>
</blockquote>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091630</guid><dc:creator><![CDATA[Thread]]></dc:creator><pubDate>Wed, 05 Jul 2006 09:17:14 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 10:37:48 GMT]]></title><description><![CDATA[<p>Deklarier doch die CS als static.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091673</guid><dc:creator><![CDATA[connan]]></dc:creator><pubDate>Wed, 05 Jul 2006 10:37:48 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 12:03:16 GMT]]></title><description><![CDATA[<p>Habe die Variable als static deklariert.<br />
Doch dann bekomme ich folgende Fehlermeldung:</p>
<blockquote>
<p>AdoDatabase error LNK2001: Nichtaufgelöstes externes Symbol &quot;private: static class CCriticalSection CMyThread::criticalSection&quot; (?criticalSection@CMyThread@@0VCCriticalSection@@A)</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1091735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091735</guid><dc:creator><![CDATA[Thread]]></dc:creator><pubDate>Wed, 05 Jul 2006 12:03:16 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 13:35:27 GMT]]></title><description><![CDATA[<p>Du musst die Variable noch definieren, wie jeden static-Member. Für jemanden, der Threads benutzt, hast du aber noch recht große Lücken bei den Grundlagen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091810</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 05 Jul 2006 13:35:27 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Wed, 05 Jul 2006 14:41:45 GMT]]></title><description><![CDATA[<p>...es fehlt also noch:</p>
<pre><code class="language-cpp">CCriticalSection CMyThread::criticalSection;
</code></pre>
<p>am Anfang deiner mythread.cpp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091882</guid><dc:creator><![CDATA[connan]]></dc:creator><pubDate>Wed, 05 Jul 2006 14:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Thu, 06 Jul 2006 14:18:23 GMT]]></title><description><![CDATA[<p>Danke<br />
für eure Hilfe<br />
es funktioniert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1092544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1092544</guid><dc:creator><![CDATA[Thread]]></dc:creator><pubDate>Thu, 06 Jul 2006 14:18:23 GMT</pubDate></item><item><title><![CDATA[Reply to CCriticalSection on Thu, 06 Jul 2006 16:57:40 GMT]]></title><description><![CDATA[<p><a href="http://www.henkessoft.de/C++/MFC/mfc_einsteigerbuch_kapitel17.htm" rel="nofollow">http://www.henkessoft.de/C++/MFC/mfc_einsteigerbuch_kapitel17.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1092665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1092665</guid><dc:creator><![CDATA[heapless nad stackful]]></dc:creator><pubDate>Thu, 06 Jul 2006 16:57:40 GMT</pubDate></item></channel></rss>