Monday, June 29, 2015

VB.Net Prevent Multiple Instance Windows Application

Sometimes user accidentally double click the application exe and open multiple app that automatically consume our memory resource and make the entire CPU goes lag, to prevent that below is the code to check whether user already open the application or not.


 If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1 Then  
        MessageBox.Show("your message", "title", MessageBoxButtons.OK, MessageBoxIcon.Information)  
        End  
 End If  

Put the code in main startup form.
Hope This Help,
Tq

0 comments:

Post a Comment