-2

I'm developing an application in Visual Studio with Cpp. Under normal conditions, we can call multithreading software from the main and we don't get any errors. But why am I getting this error here?

#include <thread>

This is the code inside my Method.

private: void Getmessage()
{
    uint16_t Register_List[1];
    mb.modbus_read_holding_registers(1, 0, Register_List);
    label1->Text= System::Convert::ToString(Register_List);

}

This is the code inside my one button event.

public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
    label1->Text = "ok";
    mb.modbus_set_slave_id(1);
    mb.modbus_connect();
    if (mb.is_connected())
    {
        label2->Text = "connected";
        std::thread first(Getmessage);

        first.join();
    }
    else
    {
        label2->Text = "Error";
    }
};

I was able to do this comfortably on other platforms, but here I am getting this error. Error : No instance of constructor "std::thread::thread" matching argument list.

I tried a lot of things I researched and went back to the simplest.

273K
  • 19,191
  • 8
  • 34
  • 47
ugurrrn
  • 3
  • 3
  • If you create a thread with the following thread::join, then you don't need a thread. – 273K Jun 02 '22 at 03:38
  • 1
    Does this answer your question? [Start thread with member function](https://stackoverflow.com/questions/10673585/start-thread-with-member-function) – 273K Jun 02 '22 at 03:41
  • Thank you sir, I tried it but I couldn't implement it, do I have to do it through another class? Can I start thread in form class? – ugurrrn Jun 02 '22 at 04:41

0 Answers0