我有两种形式。我想同时启动它们。在主程序中,我遵循 Md Kamruzzaman Pallob 的建议。以下代码是更新版本,但还是不行。
错误是错误 C3350:'System::Threading::ThreadStart':委托构造函数需要 1 个参数
#include "stdafx.h"
#include "Form1.h"
#include "Form3.h"
using namespace MySearch;
using namespace System;
using namespace System::Threading;
public ref class ThreadX{
public: ThreadX(){}
public: static void func1()
{
Application::Run(gcnew Form1());
}
public: static void func2()
{
Application::Run(gcnew Form3());
}
};
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
ThreadX^ o1 = gcnew ThreadX();
ThreadX^ o2 = gcnew ThreadX();
Thread^ th = gcnew Thread(gcnew ThreadStart(o1, &ThreadX::func1));
Thread^ th1 = gcnew Thread(gcnew ThreadStart(o2, &ThreadX::func2));
th->Start();
th1->Start();
return 0;
}