PowerTCP SSH and SFTP for .NET
StateChanged Event
Example 




Raised when the value of the State property changes, or a call to any Authenticate method returns.
Syntax
'Declaration
 
Public Event StateChanged As EventHandler
'Usage
 
Dim instance As SshConnection
Dim handler As EventHandler
 
AddHandler instance.StateChanged, handler
public event EventHandler StateChanged
public: __event EventHandler* StateChanged
public:
event EventHandler^ StateChanged
Remarks

Connection.GetRemainingAuthMethods can raise this event if its return value is not cached from a previous authentication attempt.

This method is raised on the UI thread if the SynchronizingObject is set. Otherwise this event is raised on a worker thread.

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

Reference

SshConnection Class
SshConnection Members


PowerTCP SSH and SFTP for .NET Documentation Version 7.0
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic