3 Replies - 298 Views - Last Post: 09 April 2012 - 07:27 PM Rate Topic: -----

#1 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 272
  • Joined: 27-November 11

Checking if an Application is running

Posted 09 April 2012 - 06:32 PM

Hello everyone, I'm writing a program where the user will put in a list of sites/programs and then the program will start all those sites/programs are running. However, the problem I'm having is that when opening sites (in default browser) that they will all open in a different window because of the fact that(I think) the first window still isn't fully open when the second site is being started, so right now what I'm doing is I'm using Thread.Sleep() that will wait for a certain period of time, but the problem is that when the computer first start, applications won't start as quickly, but later, it'll start faster, so I want it to be as fast as possible as I don't want the user to be waiting for like 10 minutes for their programs to start. Anyway, so my idea was to check if the previous program had started yet by checking if it is running, so is there any way to check the running applications or to check if a certain application is running?

Is This A Good Question/Topic? 0
  • +

Replies To: Checking if an Application is running

#2 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

Re: Checking if an Application is running

Posted 09 April 2012 - 06:40 PM

Worth a look here.
It uses the System.Dyagnostics namespace :)
Was This Post Helpful? 1
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1211
  • View blog
  • Posts: 4,126
  • Joined: 27-January 10

Re: Checking if an Application is running

Posted 09 April 2012 - 06:56 PM

Something like would do the trick.

using System.Diagnostics;

//From a .txt file? App.settings file? :)/>
var names = LoadNamesOfProgramsYouWant(); 
foreach(var name in names)
{
    if(Process.GetProcesses().Any(proc => proc.ProcessName.Contains(name)))
    {
        LaunchThisApp(name);
    }
}


This post has been edited by Sergio Tapia: 09 April 2012 - 06:57 PM

Was This Post Helpful? 2
  • +
  • -

#4 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 272
  • Joined: 27-November 11

Re: Checking if an Application is running

Posted 09 April 2012 - 07:27 PM

Thanks! I got it to work, I structured it a bit like Sergio Tapia except using a for loop instead of foreach, and also I put a while loop for delay instead. So thanks to both of you! It helped a lot!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1