Process.Handle
is returning different values every time, is this correct?
From msdn, "The handle that the operating system assigned to the associated process when the process was started. The system uses this handle to keep track of process attributes."
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.handle?view=netcore-3.1
Isn't supposed to be constant if not unique?
Tried different ways of getting the process but the Handle is different everytime. Ex:
Process.GetProcesses().FirstOrDefault(...)
OR
Process.GetProcessById(123)
OR
Process.GetProcessesByName("xyz")
I'm trying to hold a process id of a process that is launched by my application and this id will be used "later" to get the process from the running processes to stop it, if it is still running in a particular case. I don't want to check with name as the same application can be launched externally.
Trying to add another layer of validation to make sure any other process is not running with same id later(if my expected process is already stopped and the same id is used for restarting same application or any other application)
Is the Process.Handle
property expected to be varying or Any other way to do the same?