Skip to content

Instantly share code, notes, and snippets.

@Kogarasi
Created July 19, 2012 05:51
Show Gist options
  • Save Kogarasi/3141039 to your computer and use it in GitHub Desktop.
Save Kogarasi/3141039 to your computer and use it in GitHub Desktop.
cs_lambda
public class WebClientWrapper
{
public static void WebGetAsync( string url, System.Action<string> callback_func )
{
System.Net.WebClient wc = new System.Net.WebClient();
// 本来の引数型は void ( object, System.Net.DownloadStrignCompletedEventArgs )
// ラムダ関数でラップしてWebGetAsyncの第二引数の関数(System.Action<string> callback_func)を呼び出す。
wc.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler( ( o, e ) => {
callback_func( e.Result );
});
wc.DownloadStringAsync( new System.Uri( url ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment