이 부분을 바탕으로 question 나는 Jim Mischel 권장 사항을 기반으로 솔루션에 waithandles/eventwaithandle을 사용하기로 결정했습니다. 나는 거의 "일하고있다. 코드는 다음과 같습니다다중 프로세스 및 대기 핸들
Private Sub InitDeploymentCheck()
moDeploymentCheck = New TRS.Deployment.TRSDeploymentCheck(EnvironmentVariables.Environment, AppDomain.CurrentDomain.BaseDirectory.Contains("bin"), MDIMain)
AddHandler moDeploymentCheck.DeploymentNeeded,
Sub()
moTimer = New System.Windows.Forms.Timer()
moTimer.Interval = 300000 '5 minutes
moTimer.Enabled = True
AddHandler moTimer.Tick,
Sub()
'check to see if the message box exist or not before throwing up a new one
'check to see if the wait handle is non signaled, which means you shouldn't display the message box
If waitHandle.WaitOne(0) Then
'set handle to nonsignaled
waitHandle.Reset()
MessageBox.Show(MDIMain, "There is a recent critical deployment, please re-deploy STAR to get latest changes.", "Critical Deployment", MessageBoxButtons.OK, MessageBoxIcon.Warning)
'set the handle to signaled
waitHandle.Set()
End If
End Sub
waitHandle.Set()
MessageBox.Show(MDIMain, "There is a recent critical deployment, please re-deploy STAR to get latest changes.", "Critical Deployment", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Sub
End Sub
다시 말하지만 거의 모든 우리 애플리케이션에서 상속받은 기본 폼의 것입니다. 우리가 하나의 앱을 사용할 때 완벽하게 작동합니다. 기본 양식을 상속하고 누군가가 메시지 상자 중 하나를 클릭하면 여러 개의 응용 프로그램을 실행하는 경우 두 번째 메시지 상자가 다른 응용 프로그램에 표시되는 경우가 있습니다. 나는 원래 waithandle을 정적/공유로 선언하고 그것이 문제라고 생각했지만 그렇지 않았습니다. 나 또한 각 응용 프로그램에 자체 waithandle을 만들고 기본으로 전달하려고 시도하고 동일한 결과가 발생했습니다. 다른 응용 프로그램간에 waithandle이 공유되는 이유는 누구입니까? WaitHandle은 실제로 ManualResetEvent입니다.
어떻게 waitHandle을 만드십니까? – usr
@usr : 클래스 상단의 전용 변수입니다. Dim waitHandle as New ManualResetEvent (True) – coding4fun