I am writing a sample program with threading. I have a class called CamThread defined as follows in CamThread.h
public ref class CamThread{
public:
CamThread();
void takeImages();
private:
Driver^ driver;
};
CamThread.cpp file looks like:
using namespace System::Threading;
CamThread::CamThread(){
Driver^ newdriver;
newdriver = (Driver^)gcnew ZylaDriver();
newdriver->initCamera();
Thread^ acquireThread = gcnew Thread(gcnew ParameterizedThreadStart(this,&CamThread::takeImages));
acquireThread->Start;
};
void CamThread::takeImages(){
//Additional code.}
Main function is
int main(int argc, char* argv[]) {
CamThread^ cameraThread = gcnew CamThread();
cout << endl << "Press enter to close" << endl;
cin.ignore();
return 0;
}
The problem I'm having is that in CamThread.cpp Visual Studio 2013 has an issue with &CamThread::takeImages in ParameterizedThreadStart. It is giving me "Error: Invalid delegate initializer -- function does not match the delegate type".
It seems like I'm constructing the delegate &CamThread::takeImages incorrectly, but many of the examples I've found seem to use a similar construction (e.g. https://msdn.microsoft.com/en-us/library/system.threading.parameterizedthreadstart%28v=vs.110%29.aspx).
I've been having trouble finding other good examples.