RamblingCookieMonster/PowerShell — pull request #1 by tbyehl (2014-12-11 17:19:31+00:00)
Title: Add an escape switch for timed out threads.

I'd commented on the TechNet Gallery a way to handle hangs from timed out threads (by leaking memory). With this PR I've encapsulated that within the -noCloseOnTimeout switch. When the switch is used, powershell.dispose() will not be called on timed out threads and the runspace.close() will be skipped if any threads had timed out. If there are no time outs then it works the same as previously.

I also moved the timed out thread logging to occur before the call to dispose.

I don't have a way to test hanging a thread on-demand, but it was happening it my environment today so I had the opportunity to test this change with and without the switch.