Windows Forms应用程序中的_beginthread实现

时间:2012-12-02 15:11:08

标签: c++ cdecl

我尝试在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

如何预防?

0 个答案:

没有答案