PowerTCP Mail for .NET
InvokeEventArgs Class
Members  Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : InvokeEventArgs Class




This class is passed into EndInvoke events and provides data for these event.

Object Model

InvokeEventArgs ClassResponse Class

Syntax

Visual Basic (Declaration) 
Public Class InvokeEventArgs 
   Inherits System.EventArgs
Visual Basic (Usage)Copy Code
Dim instance As InvokeEventArgs
C# 
public class InvokeEventArgs : System.EventArgs 
Managed Extensions for C++ 
public __gc class InvokeEventArgs : public System.EventArgs 
C++/CLI 
public ref class InvokeEventArgs : public System.EventArgs 

Example

The following example demonstrates using Ftp.BeginInvoke to issue a command (in this case, CDUP) asynchronously.
Visual BasicCopy 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();
}

Remarks

A InvokeEventArgs object is passed into an EndInvoke event after a command has been sent asynchronously. This object represents the command sent to the server and the response received from the server.

Many TCP/IP protocols are based on a request/response system, where the client sends a request, and the server sends at least one reply. This continues lock-step until communication is finished. The InvokeEventArgs object encapsulates these request/reply pairs.

In PowerTCP commands are often explicitly sent using the Object.Invoke or Object.BeginInvoke methods, and transparently sent using higher-level methods. When a command is sent asynchronously an InvokeEventArgs object is returned in the event handler describing both the request and response. The response is encapsulated by the InvokeEventArgs.Response property which allows easy access to the raw and parsed response from the server. The request is represented by the InvokeEventArgs.Request property, a string containing the request sent.

If your code causes an exception, it would be returned to the handling event without you seeing it. To preclude such a condition, you should ALWAYS use a try/catch block around your event-handling code.

Inheritance Hierarchy

System.Object
   System.EventArgs
      Dart.PowerTCP.Mail.InvokeEventArgs

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.