C
C#2y 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
phaseshift2y ago
Debug There are probably no entries in your processes variable Bet the process name doesn't have a space in it...
yatta
yatta2y ago
The space is added after i tried it the first time Still it cant run even without that space
phaseshift
phaseshift2y ago
It's running...
yatta
yatta2y ago
I mean, the process still there even without that space …
phaseshift
phaseshift2y ago
Ok ... But did you debug?
yatta
yatta2y ago
Haven’t yet, i’ll try it once i comeback with my pc
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts
XUnit crashing when a stack overflow occurs.Hello, I am using XUnit to test untrusted student code. Thing is, whenever a stack overflow occurs (I need directions.i wish to learn and understand how to create and use a application window without using Winforms, WP✅ Getting a string value from a set of strings stored in a text fileI have a text file which has strings written in this following pattern: ``` Name:Age:DOB:DesignationReporting download progress with IAsyncEnumerableIs reporting progress with an `IAsyncEnumerable<T>` weird? I have the following: ```cs public interfEF Core - Code First - Add new non-null column to existing table with existing dataHi there, I would like to add a new non-null column to an existing table which contains existing daFormCollection converting value from input='text'I'm trying to pass a value (a decimal one, more specifically) through an `input="text"` _(see attach❔ Hello guys, I'm just trying to create two functionalities which's borrow and return books.https://paste.mod.gg/amnpmjcagrtk/3ActivatorUtilities.CreateInstance of a class instantiated within Program.cs 'unable to resolve type'I can verify that the two services the class takes in the constructor are correctly registered. I'm Abstract class functionsIs it fine design wise to have an abstract class A with 2 classes B and C inheriting from it, with BProtobuf deserialization not working after upgrade to .net 6Hello, I am trying to deserialize a buffer (byte array) into a model. I upgraded my solution from c