I have checked the log when the error occurs, and the following error message is output.
Based on the message, I suspect that the cause of the error is that the logon session is deleted by another process when retrieving the logon session, and thus the logon session cannot be retrieved correctly.Collection was modified; enumeration operation may not execute.
What can I do to avoid this error?