| Dart.PowerSNMP Namespace > Agent Class : Close Method (Agent) |
Disables the Agent by releasing communication resources.
[Visual Basic]
Public Sub Close() [C#]
public void Close();[C++]
public: void Close(); [C++/CLI]
public:
void Close(); Agent.Socket is null after Close is used.
The following example demonstrates opening and closing the Agent component.
[Visual Basic]
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
If (cmdStart.Text = "Start Agent") Then
'Start the Agent
Try 'Open port for receiving requests and sending responses
Agent1.Open()
cmdStart.Text = "Active"
Catch ex As Exception
ShowError(ex.Message)
End Try
Else
'Close Agent
Agent1.Close()
cmdStart.Text = "Start Agent"
End If
End Sub
[C#]
private void cmdStart_Click(object sender, System.EventArgs e)
{
if (cmdStart.Text == "Start Agent")
{
// Start the Agent
try // Open port for receiving requests and sending
responses
{
agent1.Open();
cmdStart.Text = "Active";
}
catch (Exception ex)
{
ShowError(ex.Message);
}
}
else
{
// Close Agent
agent1.Close();
cmdStart.Text = "Start Agent";
}
}
Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Send comments on this topic.
Documentation version 1.2.0.0.
© 2008 Dart Communications. All rights reserved.