I have a legacy .NET 2.0 Windows Form application that contains a form that uses a component model BackgroundWorker component.
The event handler for the DoWork event makes a call to WindowsIdentity.GetCurrent() to retrieve the identity of the user and then utilizes the Name of the identity. Recently, the call to WindowsIdentity.GetCurrent() is taking between 1-4 minutes to return.
When we moved the WindowsIdentity.GetCurrent() call to be outside of the DoWork event handler, it returns quickly. If we then pass the WindowsIdentity to the DoWork event handler, attempting to retrieve the WindowsIdentity.Name property again takes a very long time to return.
We can resolve this performance issue by making the call to WindowsIdentity.GetCurrent(), retrieving the Name, and then passing it to the DoWork event handler.
My question is if anyone knows why WindowsIdentity.GetCurrent() is performing so slowly when called within the DoWork event handler? The recent change in behavior makes the team wonder if there was an external change such as a security patch to Windows that may be related to this issue.