表达式必须是左值或函数Thread

时间:2018-12-10 12:59:04

标签: visual-c++ managed-c++

我有一个Windows窗体,该窗体具有单击 btnStart 时运行的功能。它具有无限循环,应在再次单击该按钮时将其停止。问题是循环开始时Windows窗体无响应,因此我使用了在谷歌搜索时发现的线程代码。但是它有一个错误,表达式必须是左值或函数指示符。我已经搜索了该错误,但问题与我的不同(我的意思是未使用线程)。下面是我的代码:

bool isStarting = false;


private: System::Void btnStart_Click(System::Object^  sender, System::EventArgs^  e) {
    if (isStarting) {
        isStarting = false;
        groupBox1->Enabled = true;
        btnStart->Text = "Start";
    }
    else {
        isStarting = true;
        groupBox1->Enabled = false;
        btnStart->Text = "Stop";

        fear f(handle, base_addr);
        runCode(base_addr ,hwnd, f);

        Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyForm::runCode(base_addr, hwnd, f)));
        thr1->Start();
    }
}


void runCode(long base_addr, HWND hwnd, fear f) {

    while (isStarting) {
        //long code here
    }
}

错误出现在&MyForm :: runCode 上。请帮助我只是视觉c ++的新手

0 个答案:

没有答案