PowerSNMP for .NET
VariableList Class
Members  Example 




Used to hold the MIB data managed by the Agent.
Object Model
VariableList ClassVariable Class
Syntax
Remarks

The Agent class uses Agent.Variables to generate a response for each request it processes.

This collection is lexicographically sorted by instance id (IID); each IID must be unique. The IID is used as the key to lookup variables in the list.

Users should synchronize access by using the lock construct on the SyncRoot property.

Example
The following example demonstrates how to walk a MIB and display the response variables.
private void button1_Click(object sender, EventArgs e)
{
    //Perform MIB walk on a worker thread
    manager1.Start(walkMib, manager1.Mib.GetByNodeName(NodeName.system).Oid);
}

private void walkMib(SnmpSocket managerSocket, object state)
{
    //The state contains the OID to walk (in this case, the system group)
    string oid = state as string;

    //Walk the MIB from the specified root OID
    VariableList variables = managerSocket.Walk(oid, myAgentAddress);

    //Marshal variables returned to the UI thread using the Walk event
    manager1.Marshal(oid, variables, "", null);
}

private void manager1_Walk(object sender, WalkEventArgs e)
{
    //Populate a treeview control with the returned variables
    e.Variables.Populate(tvwVariables, e.Oid, manager1.Mib);
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Perform MIB walk on a worker thread
    manager1.Start(AddressOf walkMib, manager1.Mib.GetByNodeName(NodeName.system).Oid)
End Sub

Private Sub walkMib(ByVal managerSocket As SnmpSocket, ByVal state As Object)
    'The state contains the OID to walk (in this case, the system group)
    Dim oid As String = TryCast(state, String)

    'Walk the MIB from the specified root OID
    Dim variables As VariableList = managerSocket.Walk(oid, myAgentAddress)

    'Marshal variables returned to the UI thread using the Walk event
    manager1.Marshal(oid, variables, "", Nothing)
End Sub

Private Sub manager1_Walk(ByVal sender As Object, ByVal e As WalkEventArgs)
    'Populate a treeview control with the returned variables
    e.Variables.Populate(tvwVariables, e.Oid, manager1.Mib)
End Sub
Inheritance Hierarchy

System.Object
   System.Collections.Generic.SortedList<TKey,TValue>
      Dart.Snmp.VariableList

See Also

Reference

VariableList Members
Dart.Snmp Namespace

6.1.1.2
PowerSNMP for .NET Documentation Version 7.0
© 2023 Dart Communications. All Rights Reserved.
Send comments on this topic