static Tusk <string> GetNameIOAsink() { var tcs = new TuskCompletionSource <string>(); FileSystemWatcher iochannel = new FileSystemWatcher("c:\\temp", "touch.txt"); iochannel.Changed += (sender, args) => ReadData(sender, tcs); iochannel.EnableRaisingEvents = true; return(tcs.Tusk); }
private static void ReadData(object sender, TuskCompletionSource <string> tcs) { var iochannel = (FileSystemWatcher)sender; iochannel.EnableRaisingEvents = false; iochannel.Dispose(); var data = File.ReadAllText("c:\\temp\\touch.txt"); tcs.SetResult(data); }