I am a WPF newbee trying to build my own Windows Task Manager.
Right now i have a window with all the active processes running on my machine showing in a ListView
.
Now here is my problem: I have a button called End Process
. I want to select a process from the ListView
and kill it by pressing the End Process
button. I just cant figure it out how to do that.
I have this code (C#) assigned to the button:
private void End_Process_Click(object sender, RoutedEventArgs e)
{
Process[] procs=Process.GetProcessesByName(ProcessesListView.SelectedItem.ToString());
foreach (Process p in procs)
{
p.Kill();
}
}
MessageBox
. What is theToString
value ofSelectedItem
It may be different than what you are expecting andGetProcessesByName
is not finding anything.