' The EndGetResponseCallback method
' completes a call to BeginGetResponse.
Private Shared Sub EndGetResponseCallback(ByVal ar As IAsyncResult)
Dim state As FtpState = CType(ar.AsyncState, FtpState)
Dim response As FtpWebResponse = Nothing
Try
response = CType(state.Request.EndGetResponse(ar), FtpWebResponse)
response.Close()
state.StatusDescription = response.StatusDescription
' Signal the main application thread that
' the operation is complete.
state.OperationComplete.Set()
' Return exceptions to the main application thread.
Catch e As Exception
Console.WriteLine("Error getting response.")
state.OperationException = e
state.OperationComplete.Set()
End Try
End Sub