2013-07-03 54 views
1

我正在使用MS Visual Studio 2010专业版的C++/CLI(Visual C++)项目。我有一个叫做SRecognizer的类,它使用了一些C#库。现在,它具有以下代码'系统::线程:: ThreadStart':错误

r = gcnew RTMotionDetector(); 

Thread ^detectionThread = gcnew Thread(gcnew System::Threading::ThreadStart(this,&r->start())); 

RMotionDetector类的头低于

#pragma once 
#include "MotionDetector.h" 

ref class RTMotionDetector : 
    public MotionDetector 
{ 
public: 
    RTMotionDetector(void); 
    ~RTMotionDetector(void); 
    void start(); 
    void pause(); 
    void stop(); 

private: 
    VideoCapture *cam1; 
}; 

当程序运行时,它提供了以下错误

1>------ Build started: Project: Automated Intruder Tracking System, Configuration: Debug Win32 ------ 
1>Build started 7/3/2013 1:03:49 PM. 
1>InitializeBuildStatus: 
1> Touching "Debug\Automated Intruder Tracking System.unsuccessfulbuild". 
1>GenerateTargetFrameworkMonikerAttribute: 
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files. 
1>ClCompile: 
1> All outputs are up-to-date. 
1> SRecognizer.cpp 
1>SRecognizer.cpp(38): error C2102: '&' requires l-value 
1>SRecognizer.cpp(38): error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s) 
1> 
1>Build FAILED. 
1> 
1>Time Elapsed 00:00:02.19 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

正如你所看到的,错误在于我如何创建SRecognizer中的线程,您已经拥有上面的特定代码。我对C++/CLI相当陌生,请帮忙。

+0

你已经纠正缺少 “)” 的错误?这一点很明显。它会改变什么吗? – JeffRSon

+0

@JeffRSon:非常感谢您的回复。我纠正了这个问题。现在丢失的l值和其他错误仍然存​​在 –

回答

1

这应该可以解决的编译器错误:

Thread^ detectionThread = gcnew Thread(gcnew System::Threading::ThreadStart(r, &RTMotionDetector::start)); 
+0

非常感谢!它解决了这个问题! –