我在线程编程方面遇到了一些问题,因为我很新手。
我得到了以下错误:
没有与参数列表匹配的构造函数“std :: thread :: thread”的实例
参数类型为(void())
出错位置在:
std::thread t1(TestPlay);
void CMusicTCPDlg::OnBnClickedBtplaymusic()
{
std::thread t1(TestPlay);
t1.join();
}
void CMusicTCPDlg::TestPlay()
{
if (CFugue::GetMidiOutPortCount() <= 0)
{
std::cerr << "No MIDI Output Ports found!";
exit(-1);
}
std::cout << "Playing Notes..";
CFugue::PlayMusicStringWithOpts(_T("C D E F G A B"), MIDI_MAPPER, 20);
}
我参考了一些线程页面,大部分都有一个类似于我的简单示例。
Visual Studio建议在调用函数之前使用&,但它不起作用。 我是否必须使用BackgroundWorker来完成?
非常抱歉如果这是重复的。谢谢!