2012-04-30 2 views
1

두 가지 형식이 있습니다. 나는 그 두 가지를 동시에 시작하고 싶다. 주 프로그램에서 나는 Kamruzzaman Pallob의 제안을 따른다. 다음 코드는 업데이트 버전이지만 아직 작동하지 않습니다.프로그램에서 두 개의 창 양식을 시작하려면 어떻게해야합니까?

오류는 오류 C3350입니다 : '시스템 :: 스레딩 :: 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; 

가}

답변

0

당신은 나사를 사용하여 작업을 수행 할 수 있습니다 기대하고있다. 나는 C++을 잘 모르기 때문에 유감입니다. 하지만 난 당신에게 C로 솔루션을 제공 할 수 있습니다 #

public static void func1() 
    { 
     Application.Run(new Form1()); 
    } 

    public static void func2() 
    { 
     Application.Run(new Form2()); 
    } 

    static void Main() 
    { 
     Application.EnableVisualStyles(); 
     Application.SetCompatibleTextRenderingDefault(false); 
     Thread th = new Thread(func1); 
     Thread th1 = new Thread(func2); 
     th.Start(); 
     th1.Start(); 
    } 
1

왜 그냥 다음과 같은 form1로드 이벤트를 만들지 않니? :

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { 
     Form2^ form2 = gcnew Form2; 
     form2->Show(); 
    } 

그런 다음 Form1이 열릴 때마다 Form2도 열립니다. 그것은 나를 위해 일하는 것 같다.

관련 문제