Debian Codegraph @

external/rx/Rx/NET/Samples/HOL/CS/Excercise8/Step02/Program.cs

raw
1 using System;
2 using System.Reactive.Linq;
3 using System.Windows.Forms;
4 using System.Reactive.Disposables;
5
6 namespace Excercise8
7 {
8 class Program
9 {
10 static void Main()
11 {
12 var txt = new TextBox();
13 var lst = new ListBox { Top = txt.Height + 10 };
14
15 var frm = new Form()
16 {
17 Controls = { txt, lst }
18 };
19
20 var input = (from evt in Observable.FromEventPattern(txt, "TextChanged")
21 select ((TextBox)evt.Sender).Text)
22 .Throttle(TimeSpan.FromSeconds(1))
23 .DistinctUntilChanged()
24 .Do(x => Console.WriteLine(x));
25
26 using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp)))
27 {
28 Application.Run(frm);
29 }
30 }
31 }
32 }