I have a small problem while developing an application. I want to access all process of the current session only. Currently I am using Process
class but it will return all process of all session.
Please help me to get process of the current active session only not all.
Help needed to solve the problem.
This will give you a list of the process running that are running with the same sessionID as the current process. I think that is what you want.
Process[] runningProcesses = Process.GetProcesses();
var currentSessionID = Process.GetCurrentProcess().SessionId;
Process[] sameAsThisSession =
runningProcesses.Where(p => p.SessionId == currentSessionID).ToArray();
foreach (var p in sameAsthisSession)
{
Trace.WriteLine(p.ProcessName);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With