PowerTCP Mail for .NET
StateChanged Event
Example 




Raised when the value of the State property changes.
Syntax
Public Event StateChanged As EventHandler
Dim instance As TcpBase
Dim handler As EventHandler
 
AddHandler instance.StateChanged, handler
public event EventHandler StateChanged
public: __event EventHandler* StateChanged
public:
event EventHandler^ StateChanged
Remarks

See the SynchronizingObject property for information on updating UI controls in your event handler.

This event can be raised during a Read call if the remote host closes the connection. In this scenario, a form should not be disposed of within this event handler if the Dart component was created on the form (this includes calling Form.Close if Form.Show was used to show it). Instead, the component can be created elsewhere and passed to the form, or the form can be disposed of after the posted Read returns.

Example
This example demonstrates using the StateChanged event and State property to update the UI.
private void myComponent_StateChanged(object sender, EventArgs e)
{
    if (myComponent.State == ConnectionState.Closed)
        this.Text = "Not Connected";
    else if (myComponent.State == ConnectionState.Connected)
        this.Text = "Connected to " + myComponent.RemoteEndPoint.ToString();
    else
        this.Text = "Securely connected to " + myComponent.RemoteEndPoint.ToString();
}
Private Sub myComponent_StateChanged(ByVal sender As Object, ByVal e As EventArgs)
    If myComponent.State = ConnectionState.Closed Then
        Me.Text = "Not Connected"
    ElseIf myComponent.State = ConnectionState.Connected Then
        Me.Text = "Connected to " & myComponent.RemoteEndPoint.ToString()
    Else
        Me.Text = "Securely connected to " & myComponent.RemoteEndPoint.ToString()
    End If
End Sub
See Also

Reference

TcpBase Class
TcpBase Members


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic