diff options
Diffstat (limited to 'Rx/NET/Samples/HOL/CS/Excercise6/Start/Program.cs')
-rw-r--r-- | Rx/NET/Samples/HOL/CS/Excercise6/Start/Program.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Rx/NET/Samples/HOL/CS/Excercise6/Start/Program.cs b/Rx/NET/Samples/HOL/CS/Excercise6/Start/Program.cs new file mode 100644 index 0000000..ff144f3 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise6/Start/Program.cs @@ -0,0 +1,31 @@ +using System; +using System.Reactive.Linq; +using System.Windows.Forms; +using System.Reactive.Disposables; + +namespace Excercise6 +{ + class Program + { + static void Main() + { + var txt = new TextBox(); + + var frm = new Form() + { + Controls = { txt } + }; + + var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") + select ((TextBox)evt.Sender).Text) + .Throttle(TimeSpan.FromSeconds(1)) + .DistinctUntilChanged(); + + using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) + { + Application.Run(frm); + } + + } + } +} |