UploadDataCompletedEventHandler Delegate
Collapse the table of content
Expand the table of content

UploadDataCompletedEventHandler Delegate


Represents the method that will handle the UploadDataCompleted event of a WebClient.

Namespace:   System.Net
Assembly:  System (in System.dll)

Public Delegate Sub UploadDataCompletedEventHandler (
	sender As Object,
	e As UploadDataCompletedEventArgs


Type: System.Object

The source of the event.

Type: System.Net.UploadDataCompletedEventArgs

A UploadDataCompletedEventArgs containing event data.

When you create a UploadDataCompletedEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see NIB: Events and Delegates.

The following code example demonstrates asynchronously uploading data.

Public Shared Sub UploadDataInBackground2(ByVal address As String)

	Dim client As WebClient = New WebClient()
	Dim text As String = "Time = 12:00am temperature = 50"
	Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(text)
	Dim method As String = "POST"

	AddHandler client.UploadDataCompleted, AddressOf UploadDataCallback2
	Dim uri as Uri = New Uri(address)
                      client.UploadDataAsync(uri, method, data)
End Sub

The following method is called when the upload completes.

Private Shared Sub UploadDataCallback2(ByVal sender As Object, ByVal e As UploadDataCompletedEventArgs)

    Dim data() As Byte = CType(e.Result, Byte())
    Dim reply As String = System.Text.Encoding.UTF8.GetString(data)

End Sub

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft