i have a function
void __stdcall TestThread( String^ a, String^ b)
{
MessageBox::Show( a );
MessageBox::Show( b );
_endthread();
}
And i want to create a thread like this:
_beginthread( &HWSW_GUI::Form1::TestThread , 0, NULL );
Unfortunately i’m getting an error:
Error 2 error C3374: can't take address of 'HWSW_GUI::Form1::TestThread' unless creating delegate instance d:\testvs2008\hwsw_gui\hwsw_gui\Form1.h 5177
Can someone help me please? It is driving me crazy, and i can’t it figure it out.
Thanks!
Use managed thread instead of _beginthread.
To pass parameter to the thread, use Thread(ParameterizedThreadStart) constructor: http://msdn.microsoft.com/en-us/library/1h2f2459.aspx
Generally, working with any .NET language, including C++/CLI, avoid using unmanaged stuff (like PInvoke or mixing managed/unmanaged code in C++/CLI), unless this is absolutely necessary. Most standard programming tasks may be solved using pure managed code.