Check To See If Process Is Already Running

Do you need to see if a process is already running? It’s pretty easy with the code below. I wrote this code for my console apps .NET back utility and .NET file cleaner utility.

''' <summary>
''' Check to see if the current app is already running.
''' </summary>
''' <returns><c>true</c> if app is not running, <c>false</c>.</returns>
Public Function IsProcessRunning() As Boolean
    Return If(Process.GetProcessesByName(
              Path.GetFileNameWithoutExtension(
              Assembly.GetEntryAssembly().Location)).Count() > 1, 
              True, False)
End Function
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s