Wie beende ich einen Prozess nach sagen 2 oder 3 Minuten Blick auf den folgenden Code:Kill Process nach einer bestimmten Zeit + C#
class Program
{
static void Main(string[] args)
{
try
{
//declare new process and name it p1
Process p1 = Process.Start("iexplore", "http://www.google.com");
//get starting time of process
DateTime startingTime = p1.StartTime;
Console.WriteLine(startingTime);
//add a minute to startingTime
DateTime endTime = startingTime.AddMinutes(1);
//I don't know how to kill process after certain time
//code below don't work, How Do I kill this process after a minute or 2
p1.Kill(startingTime.AddMinutes(2));
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Problem with Process:{0}", ex.Message);
}
}
}
so möchte ich, dass der IE-Fenster nach 2 Minuten
p1.WaitForExit (60000); // DateTime endTime2; p1.SchließenMainWindow(); // endTime2 = p1.ExitTime; p1.Close(); – Developer