This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$job = $null; | |
function Start-MLVPN() { | |
$job = Start-Job -Name "Medialab VPN" -ScriptBlock { | |
for(;;) { | |
if (-not (Test-Connection -Quiet ssaquadev01.medialab.nl)) { | |
rasdial "Medialab VPN" /disconnect | |
rasdial "Medialab VPN" marcus XXXX; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cleanup = {} | |
trap { &$cleanup; } | |
# do stuff | |
$cleanup = add-cleanop { <# delete stuff #> } $cleanup; | |
function add-cleanop($cleanop, $existing = {}) { | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Task.WaitAll(_sProcesses.Select(p => _ReadFromConsoleAsync(p)).ToArray()); | |
private static async Task _ReadFromConsoleAsync(Process p) | |
{ | |
// Starst two tasks, waiting for any to complete and restarting one that just completed for next line. | |
Task<String> stdoutTask, stderrTask; | |
using (var stdoutReader = p.StandardOutput) | |
using (var stderrReader = p.StandardError) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// Example usage: | |
var inst = _Implement.Interface<ISomeInterface>(new | |
{ | |
AMethod = new Func<String, Int32>(s => Int32.Parse(s)), | |
Foobar = new | |
{ | |
get = "foobar", | |
set = new Action<String>(s => {}) | |
} |