I'm debugging a test that periodically raises an IOException
, noting that a file can not be deleted because it is being used by another process. I suspect that the process is indeed my test harness, and that some other thread in the process hasn't disposed of its file resources when I expected it to.
Is there a tool that I can use to determine which thread holds the impeding lock? If I can identify the thread, then I can inspect its call stack and at least try to determine why the resource is not yet disposed. The SOS debugging tool looks promising, but I don't see any feature that would remove a fair amount of guesswork from my investigation.
One thought is to identify the native OS thread-ID, which then can be mapped to a managed thread ID via SOS. How would I accomplish the former?