Created
July 19, 2012 05:51
-
-
Save Kogarasi/3141039 to your computer and use it in GitHub Desktop.
cs_lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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