gFinger 손끝으로 만드는 세상

prevent launching my app multiple times +1

Program 2번 실행 방지


Main Program에서 아래 굵은 부분을 추가

        static System.Threading.Mutex singleton = new System.Threading.Mutex(true, "ssPLCADS");
        [STAThread]
        static void Main()
        {

            // Prevent launching my app multiple times
            if (!singleton.WaitOne(TimeSpan.Zero, true))
            {
                //there is already another instance running!
                MessageBox.Show("Instance already running");
                Application.Exit();
            }
            else
            {

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FormMain());
            }
        }


**  출처 : https://stackoverflow.com/questions/93989/prevent-multiple-instances-of-a-given-app-in-net

'컴퓨터 이야기 > c#' 카테고리의 다른 글

Text File Save Dialog  (0) 2018.06.09
File Name을 선택해서 Text 파일 읽기  (0) 2018.06.09
How to move and resize a form without a border?  (0) 2018.06.09
Form을 Drag해서 이동  (0) 2018.06.09
Tray로 Form을 Icon화 하기  (0) 2018.06.06