无效的委托初始值设定项 -- 函数与委托类型不匹配

invalid delegate initializer -- function does not match the delegate type

我试图在 Visual C++ 中创建一个线程,但出现了这个错误 invalid delegate initializer -- function does not match the delegate type 这被应用到我将我的方法传递到线程的地方。

COM_Selector^ port;
    Thread^ t;

    public: void thread_method(Object^ data) {
        port->checkConnection(t);
    }

    private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
        t = gcnew Thread(gcnew ThreadStart(this, thread_method));
        try {
            if (!t->IsAlive) {
                t->IsBackground = true;
                t->Start();
            }
            else {
                t->IsBackground = true;
            }
        }
        catch (Exception^ ex) {
            Console::WriteLine(ex);
        }
    }
    ```

我通过将它设为 ParameterizedThreadStart 来修复它,因为我在我提到的方法中有一个参数,所以我将该行代码更改为 --

t = gcnew Thread(gcnew ParameterizedThreadStart(this, &MyForm::thread_method));