1

我尝试在 Windows 窗体应用程序中使用简单的 _beginthread 函数创建线程(我通过制作控制台应用程序成功地做到了。

private: System::Void __cdecl counter() {
             do {
                 Sleep(1);
                 stan++;
                 label1->Text = stan.ToString();
             } while(true);
             _endthread();
         }

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             button1->Enabled = false;
             HANDLE licznik = (HANDLE) _beginthread(counter(), 0, 0);
         }
};`

我的错误(和警告)是:

c:\users\artur\desktop\clock\thread_clock\thread_clock\Form1.h(117): warning C4441: calling convention of '__cdecl ' ignored; '__clrcall ' used instead 1>c:\users\artur\desktop\clock\thread_clock\thread_clock\Form1.h(128): error C2664: '_beginthread' : cannot convert parameter 1 from 'void' to 'void (__cdecl *)(void *)' 1> Expressions of type void cannot be converted to other types

如何防止这种情况?

4

0 回答 0