UploadStringCompletedEventHandler 대리자

정의

UploadStringCompletedWebClient 이벤트를 처리할 메서드를 나타냅니다.

public delegate void UploadStringCompletedEventHandler(System::Object ^ sender, UploadStringCompletedEventArgs ^ e);
public delegate void UploadStringCompletedEventHandler(object sender, UploadStringCompletedEventArgs e);
type UploadStringCompletedEventHandler = delegate of obj * UploadStringCompletedEventArgs -> unit
Public Delegate Sub UploadStringCompletedEventHandler(sender As Object, e As UploadStringCompletedEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
UploadStringCompletedEventArgs

이벤트 데이터가 포함된 UploadStringCompletedEventArgs입니다.

예제

다음 코드 예제에서는 문자열을 비동기적으로 업로드 하는 방법을 보여 줍니다.

void UploadStringInBackground2( String^ address )
{
   WebClient^ client = gcnew WebClient;
   Uri ^uri = gcnew Uri(address);
   String^ data = "Time = 12:00am temperature = 50";

   client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback2 );
   client->UploadStringAsync( uri, data );
}
public static void UploadStringInBackground2(string address)
{
    WebClient client = new WebClient();
    Uri uri = new Uri(address);
    string data = "Time = 12:00am temperature = 50";
    client.UploadStringCompleted += new UploadStringCompletedEventHandler(UploadStringCallback2);
    client.UploadStringAsync(uri, data);
}
Public Shared Sub UploadStringInBackground2(ByVal address As String)

    Dim client As WebClient = New WebClient()
    Dim data As String = "Time = 12:00am temperature = 50"
    AddHandler client.UploadStringCompleted, AddressOf UploadStringCallback2
                Dim uri as Uri = New Uri(address)
    client.UploadStringAsync(uri, data)
End Sub

다음 메서드는 업로드가 완료 되 면 호출 됩니다.

void UploadStringCallback2( Object^ /*sender*/, UploadStringCompletedEventArgs^ e )
{
   String^ reply = dynamic_cast<String^>(e->Result);
   Console::WriteLine( reply );
}
private static void UploadStringCallback2(Object sender, UploadStringCompletedEventArgs e)
{
    string reply = (string)e.Result;
    Console.WriteLine(reply);
}
Private Shared Sub UploadStringCallback2(ByVal sender As Object, ByVal e As UploadStringCompletedEventArgs)
    Dim reply As String = CStr(e.Result)
    Console.WriteLine(reply)
End Sub

설명

UploadStringCompletedEventHandler 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상