Created
July 3, 2023 18:57
-
-
Save ebubekirbastama/56399968cf81bada4d43f5fc07faa1a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
class Program | |
{ | |
static void Main() | |
{ | |
// İşlemi başlatma | |
Process process = new Process(); | |
process.StartInfo.FileName = "notepad.exe"; | |
process.Start(); | |
Console.WriteLine("Notepad başlatıldı. Kapatmak için bir tuşa basın."); | |
Console.ReadKey(); | |
// İşlemi kapatma | |
if (!process.HasExited) | |
{ | |
process.CloseMainWindow(); // Kapatma penceresini gönder | |
process.WaitForExit(1000); // 1 saniye bekleyerek kapatmayı bekleyin | |
// İşlem hala çalışıyorsa, zorla kapat | |
if (!process.HasExited) | |
{ | |
process.Kill(); | |
} | |
} | |
Console.WriteLine("İşlem kapatıldı."); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment