| Visual Basic (Declaration) | |
|---|---|
Public ReadOnly Property Exception As Exception | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As InvokeEventArgs Dim value As Exception value = instance.Exception | |
| C# | |
|---|---|
public Exception Exception {get;} | |
| Managed Extensions for C++ | |
|---|---|
public: __property Exception* get_Exception(); | |
| C++/CLI | |
|---|---|
public: property Exception^ Exception { Exception^ get(); } | |
Property Value
If any exception occurred during the asynchronous operation, this property will contain an Exception object describing the exception.The following example demonstrates using Ftp.BeginInvoke to issue a command (in this case, CDUP) asynchronously.
| Visual Basic | Copy Code |
|---|---|
' Set server and user properties. This will allow calling of other ' Ftp Component methods with the log in taking place "behind the scenes" Ftp1.Server = "MyFTPServer" Ftp1.Username = "blah" Ftp1.Password = "mypass" ' Issue CDUP command asynchronously, upon completion the EndInvoke Event will be fired. Ftp1.BeginInvoke(Dart.PowerTCP.Ftp.FtpCommand.ChangeDirUp, Nothing, Nothing) ' Report Debug.WriteLine("CDUP command sent.") ' When the BeginInvoke operation has completed, the EndInvoke Event will fire. Private Sub Ftp1_EndInvoke(ByVal sender As Object, ByVal e As Dart.PowerTCP.Ftp.InvokeEventArgs) Handles Ftp1.EndInvoke ' If an error occurred during the asynchronous method, it would ' be returned in the event. Be sure to check for it. If e.Exception Is Nothing Then Debug.WriteLine("Command issued " + e.Request) Debug.WriteLine("Response received " + e.Response.ToString(); Else Debug.WriteLine(e.Exception.Message) End If ' Close the connection Ftp1.Close() End Sub | |
| C# | Copy Code |
|---|---|
// Set server and user properties. This will allow calling of other // Ftp Component methods with the log in taking place "behind the scenes" ftp1.Server = "MyFTPServer"; ftp1.Username = "blah"; ftp1.Password = "mypass"; // Issue CDUP command asynchronously, upon completion the EndInvoke Event will be fired. ftp1.BeginInvoke(Dart.PowerTCP.Ftp.FtpCommand.ChangeDirUp, null, null); // Report Debug.WriteLine("CDUP command sent."); // When the BeginInvoke operation has completed, the EndInvoke Event will fire. private void ftp1_EndInvoke(object sender, Dart.PowerTCP.Ftp.InvokeEventArgs e) { // If an error occurred during the asynchronous method, it would // be returned in the event. Be sure to check for it. if(e.Exception == null) { Debug.WriteLine("Command issued " + e.Request); Debug.WriteLine("Response received " + e.Response); } else { Debug.WriteLine("Error: " + e.Exception.Message); } // Close the connection ftp1.Close(); } | |
Check this property to tell if an exception occurred during the asynchronous operation. If this property is null, no exception occurred.
The exception property is useful for checking exceptions and handling them appropriately. For example, if a bad command was sent to the server, a ProtocolException may be thrown. You could check this property to see if it was of type ProtocolException, than handle appropriately.
Target Platforms: Microsoft .NET Framework 2.0
Copy Code