설명
vb.net 중복실행 방지 -2가지-

1번 코드는 vb.net 를 처음 시작할때 사용하던 소스인데 폼을 닫고 다시 열때 문제가 발생 하는것 말고는 저를 많이 도와줬던 놈입니다.

-----------코드 1번-----------
Dim bCreated As Boolean
Dim mtx As New System.Threading.Mutex(True, "이름", bCreated)
If Not bCreated Then
MessageBox.Show("Program already started!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.ExitThread()
End If
-----------코드 1번-----------

2번 코드는 1번의 문제점 때문에 코드가 길어지는 문제가 발생해서 새롭게 찾아낸 코드 입니다.

훨신 깔끔하네요.

-----------코드 2번-----------
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
MsgBox("프로그램이 이미 실행중입니다!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Me.Text)
End
End If

이 게시물을

공유하기

SEARCH

MENU NAVIGATION