2

我正在为 Windows 开发一个应用程序,其中需要运行三个进程:_thread_EEG(采集)、_thread_MachineLearning(处理)、_thread_Interface(接口)。第二个过程使用第一个过程的数据,第三个过程需要第二个过程的结果。

class uMotor{
private:
    long _endTime;

    bool _busyBuffer;
    bool _busyLabel;

    Raw  _Shared_buffer;
    char _Shared_label ;

    uEEG _gtec;
    Interface _screen;

    void _EEG            (long endTime);
    void _MachineLearning(long endTime);
    void _Interface      (long endTime);

    DWORD __stdcall _Thread_EEG(LPVOID arg){
        uMotor *yc_ptr = (uMotor*)arg;
        yc_ptr->_EEG(_endTime);
        return 1;
    }

    DWORD __stdcall _Thread_MachineLearning(LPVOID arg){
        uMotor *yc_ptr = (uMotor*)arg;
        yc_ptr->_MachineLearning(_endTime);
        return 1;
    }

    DWORD __stdcall _Thread_Interface(LPVOID arg){
        uMotor *yc_ptr = (uMotor*)arg;
        yc_ptr->_Interface(_endTime);
        return 1;
    }

public:
    uMotor();
    void BCI();
    ~uMotor();
};

线程在函数中调用uMotor::BCI()

void uMotor::BCI(){
    const long NUM_SECONDS_RUNNING = 9;

    long startTime = clock();
    long endTime = startTime + NUM_SECONDS_RUNNING * CLOCKS_PER_SEC;

    HANDLE Handle_Thread_EEG             = 0;
    HANDLE Handle_Thread_MachineLearning = 0;
    HANDLE Handle_Thread_Interface       = 0;

    Handle_Thread_EEG = CreateThread(NULL, 0, _Thread_EEG, &endTime, 0, NULL);
    Handle_Thread_EEG = CreateThread(NULL, 0, _Thread_MachineLearning, &endTime, 0, NULL);
    Handle_Thread_EEG = CreateThread(NULL, 0, _Thread_Interface, &endTime, 0, NULL);
}

在函数CreateThread中,Visual Studio 2015 显示错误argument of type "DWORD(_stdcall uMotor::*)(LPVOID arg)" is incompatible with parameter of type "LPTHREAD_START_ROUTINE"

我究竟做错了什么?

4

1 回答 1

1

线程函数必须是静态的,所以在...static之前添加DWORD __stdcall

此外,第四个参数 toCreateThread是例程参数。您期望指向 的指针uMotor,但&endTime改为传递。替换&endTimethis

于 2016-05-30T16:25:50.990 回答