Code Paste

2014/03/31

Code Paste during the years I maintains code snippets as notes for myself.recently goes over it and thought it might be useful to some of you, so I decided to publish it on my blog. you can see my code snippet at http://codepaste.net/searchall you have to do is to fill the "By" filed with my name and click search. enjoy it
no comments

Observable.FromAsync is it the right choice?

2014/03/22

Observable.FromAsync is it the right choice? one of the most common RX's practice is to use Observable.FromAsync for executing asynchronous IO operations. typical code may look like: Code Snippet var webClient = new WebClient(); IObservable<string> uris = ...; var dataStream = from uri in uris                     from data in Observable.FromAsync(                         () => webClient.DownloadDataTaskAsync(uri))                     select data; behind the scenes RX set a Task continuation (ContinueWith) and propagate the result through AsyncSubject, actually it is a bit complex and messy implementation combination with TPL Dataflow (.NET 4.5) may offer better solution to asynchronous...

Generic restrictions

2014/03/18

Generic restrictions can you predict the output of the following code snippet? Code Snippet static void Main(string args) {     var b = new B();     var g = new General<B>();     g.Exec(b); }   public class A {     public void Print()     {         Console.WriteLine("A");     } } public class B:A {     public void Print()     {         Console.WriteLine("B");     } }   public class General<T>     where T:A {     public void Exec(T t)     {         t.Print();     } } first try to predict before F5 and then give it a try. you might not expect to see so...
one comment