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?
Checking if an Application is running
Page 1 of 13 Replies - 296 Views - Last Post: 09 April 2012 - 07:27 PM
Replies To: Checking if an Application is running
#2
Re: Checking if an Application is running
Posted 09 April 2012 - 06:40 PM
#3
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
#4
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!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|