Windows 응용 프로그램과 dll (Windows 양식)을 열려고 시도하는 중 (ActivationCheck), 현재 스레드를 일시 중지하려고 시도하는 스레드가 새 스레드를 엽니 다. (ActivationCheck) 폼 이벤트가 true를 리턴 할 때까지 기다렸다가 주 스레드를 계속 진행합니다. 누군가 내가 무엇을 잘못했는지 보여 주실 수 있습니까? - 감사합니다.Windows Forms - 별도의 스레드를 걷어 내고 현재 스레드를 유지하는 방법
static class Program
{
private static SplashScreen splash;
private static bool quitApp;
private static bool activationFinished;
[STAThread]
static void Main()
{
Thread thread = new Thread(ActivationCheck);
thread.Start();
do
{
Thread.Sleep(1000);
} while (activationFinished);
if (!quitApp)
{
Thread.Sleep(0);
// WizardRun();
Application.Run(new Main(ref splash));
}
}
}
private static void ActivationCheck()
{
splash.SetStatus = "Checking License...";
Guid productId = new Guid(Properties.Settings.Default.ProductId);
Guid versionId = new Guid(Properties.Settings.Default.VersionId);
Client.UI.EntryPoint entryPoint = new EntryPoint();
activationFinished = false;
Client.BLL.ProductActivation.GenerateTrialLicense(productId1, versionId2, EditionId3);
entryPoint.IniatePlugin(productId, versionId);
entryPoint.PluginFinished += new EventHandlers.PluginFinishEventHandler(entryPoint_PluginFinished);
}
static void entryPoint_PluginFinished(bool forceQuit)
{
quitApp = forceQuit;
activationFinished = true;
}
Marc가 말했듯이, 표시된 것은 두 번째 스레드가 필요함을 의미하지 않습니다. 내 응용 프로그램에 사용하는 플러그인 논리는 MainForm의 Load 이벤트 핸들러에서 기본 스레드의 일부로 발생합니다. –
누군가 정말로 새로운 스레드를 생성해서는 안된다는 말을 들었습니다.이 경우에는 활성화 확인이 차단 호출이되고 스레드는 호출자를 차단하지 않도록 설계되어 새로운 스레드를 생성합니다. 네가하고 싶은 것이 아니라, –