C
C#3y ago
yatta

How to kill a process ?

I just know about process killing and try to test it, here is my code:
using System.Diagnostics;

var processes = Process.GetProcessesByName("Sublime Text ");
foreach(var process in processes)
{
process.Kill();
}
Console.WriteLine("Process is killed");
using System.Diagnostics;

var processes = Process.GetProcessesByName("Sublime Text ");
foreach(var process in processes)
{
process.Kill();
}
Console.WriteLine("Process is killed");
When I run the program, there's no error occurred but the Sublime Text process doesn't killed, isn't killing a process means we have it vanished in Task Manager ?. Since there is no error so I have no idea where i'm wrong
7 Replies
phaseshift
phaseshift3y ago
Debug There are probably no entries in your processes variable Bet the process name doesn't have a space in it...
yatta
yattaOP3y ago
The space is added after i tried it the first time Still it cant run even without that space
phaseshift
phaseshift3y ago
It's running...
yatta
yattaOP3y ago
I mean, the process still there even without that space …
phaseshift
phaseshift3y ago
Ok ... But did you debug?
yatta
yattaOP3y ago
Haven’t yet, i’ll try it once i comeback with my pc
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server