UploadFileCompletedEventHandler デリゲート
アセンブリ: System (system.dll 内)

Public Delegate Sub UploadFileCompletedEventHandler ( _ sender As Object, _ e As UploadFileCompletedEventArgs _ )
public delegate void UploadFileCompletedEventHandler ( Object sender, UploadFileCompletedEventArgs e )
public delegate void UploadFileCompletedEventHandler ( Object^ sender, UploadFileCompletedEventArgs^ e )
/** @delegate */ public delegate void UploadFileCompletedEventHandler ( Object sender, UploadFileCompletedEventArgs e )

UploadFileCompletedEventHandler デリゲートを作成する場合は、イベントを処理するメソッドを識別してください。イベントをイベント ハンドラに関連付けるには、デリゲートのインスタンスをイベントに追加します。デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラが呼び出されます。イベント ハンドラ デリゲートの詳細については、「イベントとデリゲート」を参照してください。

非同期的にファイルをアップロードするコード例を次に示します。
' Sample call: UploadFileInBackground("http:' www.contoso.com/fileUpload.aspx", "data.txt") Public Shared Sub UploadFileInBackground(ByVal address As String, ByVal fileName As String) Dim waiter As System.Threading.AutoResetEvent = New System.Threading.AutoResetEvent(False) Dim client As WebClient = New WebClient() Dim method As String = "POST" Dim uri as Uri = New Uri(address) ' Specify that that UploadFileCallback method gets called ' when the file upload completes. AddHandler client.UploadFileCompleted, AddressOf UploadFileCallback client.UploadFileAsync(uri, method, fileName, waiter) ' Block the main application thread. Real applications ' can perform other tasks while waiting for the upload to complete. waiter.WaitOne() Console.WriteLine("File upload is complete.") End Sub
// Sample call: UploadFileInBackground("http://www.contoso.com/fileUpload.aspx", "data.txt") public static void UploadFileInBackground (string address, string fileName) { System.Threading.AutoResetEvent waiter = new System.Threading.AutoResetEvent (false); WebClient client = new WebClient (); Uri uri = new Uri(address); string method = "POST"; // Specify that that UploadFileCallback method gets called // when the file upload completes. client.UploadFileCompleted += new UploadFileCompletedEventHandler (UploadFileCallback); client.UploadFileAsync (uri, method, fileName, waiter); // Block the main application thread. Real applications // can perform other tasks while waiting for the upload to complete. waiter.WaitOne (); Console.WriteLine ("File upload is complete."); }
Public Shared Sub UploadFileCallback(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs) Dim waiter As System.Threading.AutoResetEvent = CType(e.UserState, System.Threading.AutoResetEvent) Try Dim reply As String = System.Text.Encoding.UTF8.GetString(e.Result) Console.WriteLine(reply) Finally ' If this thread throws an exception, make sure that ' you let the main application thread resume. waiter.Set() End Try End Sub
public static void UploadFileCallback (Object sender, UploadFileCompletedEventArgs e) { System.Threading.AutoResetEvent waiter = (System.Threading.AutoResetEvent)e.UserState;; try { string reply = System.Text.Encoding.UTF8.GetString (e.Result); Console.WriteLine (reply); } finally { // If this thread throws an exception, make sure that // you let the main application thread resume. waiter.Set (); } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からUploadFileCompletedEventHandler デリゲートを検索する場合は、下記のリンクをクリックしてください。

- UploadFileCompletedEventHandler デリゲートのページへのリンク