Windows logged in user's SessionId is changed when the machine comes out of hibernate
I have a windows service written in c# which monitors the session of all the logged in windows users, I get the correct session id in the windows service for the logged in users when they lock / unlock the machine.
I have noticed sometimes that when the machine resumes from hibernate and when the user unlocks the machine, the session id for that user is not the actual session id that was allocated to the user instead it is some weird long number, it ranges from 28 to 6422639 or any other big number. I noticed that this does not happen consistently. I checked the session id for the applications running for that user session in task manager and it shows the correct session id there. Has anyone seen this problem? I have seen this problem in Windows XP, Vista and 7. I have not tried in Windows 2003 or 2008 hence I don't know how it works there.
If anyone has seen this issue can you tell me how have you fixed it or work around for it?
8/22/2022 - Mon
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!