Threading Problem
-
hi. i have a class like this :
public ref class MyClass : public IDisposable
{
.
.
.
public: MyClass();
private: void Wait();
.
.
.
}and the cpp file:
MyClass::MyClass()
{
// Create a new thread to wait for events
Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
t->Name = "Event Thread";
t->Start();
}in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.
sometimes 0 can be 1
-
hi. i have a class like this :
public ref class MyClass : public IDisposable
{
.
.
.
public: MyClass();
private: void Wait();
.
.
.
}and the cpp file:
MyClass::MyClass()
{
// Create a new thread to wait for events
Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
t->Name = "Event Thread";
t->Start();
}in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.
sometimes 0 can be 1
-
hi. i have a class like this :
public ref class MyClass : public IDisposable
{
.
.
.
public: MyClass();
private: void Wait();
.
.
.
}and the cpp file:
MyClass::MyClass()
{
// Create a new thread to wait for events
Thread^ t = gcnew Thread(gcnew ThreadStart(&MyClass::Wait));
t->Name = "Event Thread";
t->Start();
}in compile i got this error : "error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)" I've looked in msdn and saw a example that exactly used this way for threading but there was no error in compilation. thank you for help.
sometimes 0 can be 1
erfi wrote:
I've looked in msdn and saw a example that exactly used this way
Exactly? I have a feeling the Wait() function was static in the example. Using a non-static function as you've shown won't work because a MyClass object (instance) is required to make the call to Wait(). You'd have to pass an instance to the delegate constructor. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: