C #, TPL, parallel extensions, many new ways to perform asynchronous operations Async CTP, Reactive Extensions What I was surprised The following will be the simplest way to parallel the benefits and processing of the following: proviso that when files can be fetched at any time Precisely what is a pipelined way Here RX way it will replace the steam flowing streams extend Yuri: Usage: EDIT: Oops, did not require the file to be sorted. This part can be done by employing .concact which is essentially an Rx queue (second one.zip) Let's have a .streamfile extension: You can parallel web requests now, but you can serialize the file that comes in them:
foreach (string url in url) {var file = FetchFile (url); ProcessFile (file); } Is
ProcessFile can only file handle at a time and gradually be called.
FetchFile and
ProcessFile The easiest way to achieve this?
Public stable IObservable & lt; Stream & gt; RequestToStream (this IObservable & LT; string & gt; source, TimeSpan timeout) {observable .FromAsyncPattern & lt return WC in source.Select (WebRequest.Create) from s; WebResponse & gt; (Wc.BeginGetResponse, wc.EndGetResponse) () .Timeout (timeout Observable.Empty & LT; WebResponse & gt; ()) .Catch (Observable.Empty & LT; WebResponse & gt; ()) s.GetResponseStream select () ; }
New [] {"myuri.net \ file1.dat", "myuri.net \ file2.dat"} .ToObservable () .RequestToStream (TimeSpan.FromSeconds (5)). (Stream = & gt; process stream (stream)). Subscribe ();
public static IObservable & Lt; Unit & gt; Streamtophile (this is Tupal & Lt; stream, string & gt; source) {Return Overview. Check ((=) = & gt; Source. ITM 1. Async Read (). Write (File Creation (Source. Item2)); }
new [] {" Myuri.net \ file1.dat "," Myuri.net \ file2.dat "}. O Oversive () .RequestToStream (TimeSpan.FromSeconds (5)) Select. ((Stream, i) => Tuple.Create (stream, i.ToString (+ + ".dat")). Select (x = & gt; x.StreamToFile ()) .cancat (). Subscribe ();
Comments
Post a Comment