c# - How to generate new Rx events when I click on a listbox -


i have simple wpf application contains list of link. select few of them, add them "observable list" , subscribe it. observer callback download link, , proceed next 1 if of sleep. able update ui let user know item has been proceeded.

could give me doing this

many thanks.

i use observable.fromeventpattern first convert list box of link selection events observable of uri.

next, write extension method download link.

public static iobservable<bool> downloadlink(this iobservable<uri> source) {     return observable.create<bool>(observer =>     {         return source             .subscribe(onnext: async link =>             {                 using (var client = new system.net.http.httpclient())                 {                     var result = await client.getstringasync(link);                      if (issuccess)                         observer.onnext(true);                     else                         observer.onnext(false);                 }             }, onerror: observer.onerror, oncompleted: observer.oncompleted);     }); } 

finally, hook up.

uriobservable.downloadlink().observeondispatcher().subscribe( // update ui logic here ); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -