public static IEnumerable <string> UnsafeGetFilesLockedBy(List <int> pids) { if (!Utils.IsAdmin) { Log.Error("You are not running with administrator rights, therefore you cannot use the internal implementation."); yield break; } foreach (var handle in GetHandles(pids)) { var path = string.Empty; var hwnd = IntPtr.Zero; var hinf = handle; using (var mre = new ManualResetEvent(false)) { var thd = new Thread(() => { try { path = GetFilePath(hinf, ref hwnd); } catch { } finally { try { mre.Set(); } catch { } } }) { IsBackground = true }; thd.Start(); if (!mre.WaitOne(100)) { Log.Trace("Handle 0x" + handle.Handle.ToString("X") + " timed out and will now hopefully be killed."); new Thread(() => { try { Win32API.CancelIo(hwnd); Win32API.CloseHandle(hwnd); thd.Interrupt(); thd.Abort(); } catch { } }).Start(); } } if (!string.IsNullOrEmpty(path)) { yield return(path); } } }