<?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[Thread]]></title><description><![CDATA[<p>Hallo, ich arbeite grad mit Thread nun will ich die ThreadFunction in eine Klasse geben...<br />
warum brauch ich da diesen cast:</p>
<pre><code class="language-cpp">MyThreadClass *ptrMyThreadClass = static_cast&lt;MyThreadClass*&gt;(pParam);
</code></pre>
<p>weil man da den void *pParam Pointer auf einen Pointer der MyThreadClass casten muss um die Methode aufzurufen...ich kann das nicht so gut erklären*g*<br />
_beginthread will als ersten Parameter einen Funktionspointer? nun muss ja wenn ich den umweg über diese ThreadHelpFunction nicht gehen will, die methode WorkFunction static sein, damit ich die direkt _beginthread übergeben kann?</p>
<p>greets wolf</p>
<pre><code class="language-cpp">#include &lt;process.h&gt;
#include &lt;windows.h&gt;

class MyThreadClass
{
public:
	void WorkFunction();
};

void MyThreadClass::WorkFunction()
{
	cout &lt;&lt; &quot;Thread started&quot; &lt;&lt; endl;
	Sleep(1000);
}

void ThreadHelpFunction(void *pParam)
{
	MyThreadClass *ptrMyThreadClass = static_cast&lt;MyThreadClass*&gt;(pParam);
	ptrMyThreadClass-&gt;WorkFunction();
	_endthread();
}

void main(void)
{
        MyThreadClass mt;

	_beginthread(ThreadHelpFunction,			// Pointer to Thread Function
		     0,					// Stack Size set automatically
		     &amp;mt);				// Parameter: Pointer to Instance

	Sleep(5000);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/109040/thread</link><generator>RSS for Node</generator><lastBuildDate>Tue, 30 Jun 2026 08:22:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/109040.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 May 2005 09:23:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Thread on Fri, 06 May 2005 09:23:38 GMT]]></title><description><![CDATA[<p>Hallo, ich arbeite grad mit Thread nun will ich die ThreadFunction in eine Klasse geben...<br />
warum brauch ich da diesen cast:</p>
<pre><code class="language-cpp">MyThreadClass *ptrMyThreadClass = static_cast&lt;MyThreadClass*&gt;(pParam);
</code></pre>
<p>weil man da den void *pParam Pointer auf einen Pointer der MyThreadClass casten muss um die Methode aufzurufen...ich kann das nicht so gut erklären*g*<br />
_beginthread will als ersten Parameter einen Funktionspointer? nun muss ja wenn ich den umweg über diese ThreadHelpFunction nicht gehen will, die methode WorkFunction static sein, damit ich die direkt _beginthread übergeben kann?</p>
<p>greets wolf</p>
<pre><code class="language-cpp">#include &lt;process.h&gt;
#include &lt;windows.h&gt;

class MyThreadClass
{
public:
	void WorkFunction();
};

void MyThreadClass::WorkFunction()
{
	cout &lt;&lt; &quot;Thread started&quot; &lt;&lt; endl;
	Sleep(1000);
}

void ThreadHelpFunction(void *pParam)
{
	MyThreadClass *ptrMyThreadClass = static_cast&lt;MyThreadClass*&gt;(pParam);
	ptrMyThreadClass-&gt;WorkFunction();
	_endthread();
}

void main(void)
{
        MyThreadClass mt;

	_beginthread(ThreadHelpFunction,			// Pointer to Thread Function
		     0,					// Stack Size set automatically
		     &amp;mt);				// Parameter: Pointer to Instance

	Sleep(5000);

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/782581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/782581</guid><dc:creator><![CDATA[wolf1]]></dc:creator><pubDate>Fri, 06 May 2005 09:23:38 GMT</pubDate></item><item><title><![CDATA[Reply to Thread on Fri, 06 May 2005 19:35:05 GMT]]></title><description><![CDATA[<p>hallo, wäre das so ok?</p>
<p>cu</p>
<pre><code class="language-cpp">class MyThreadClass
{
public:
	static void WorkFunction(void *pParam);
};

void MyThreadClass::WorkFunction(void *pParam)
{
	cout &lt;&lt; &quot;Thread started&quot; &lt;&lt; endl;
	Sleep(1000);
	_endthread();
}

int main()
{

	        MyThreadClass mt;

	_beginthread(mt.WorkFunction,			// Pointer to Thread Function
		     0,					// Stack Size set automatically
		     &amp;mt);				// Parameter: Pointer to Instance

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/783126</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/783126</guid><dc:creator><![CDATA[wolf1]]></dc:creator><pubDate>Fri, 06 May 2005 19:35:05 GMT</pubDate></item></channel></rss>