Glossary Item Box

PowerSNMP for .NET

Using Events

Events are very important for using PowerSNMP because communications works best in applications when it occurs asynchronously. The application can send a request packet, perform other tasks, and can have an event raised when the response to the request is received. The application, however, is responsible for “hooking up” events to the application’s “event handler”.

Within the Visual Studio environment, this is most easily accomplished by dragging the Manager or Agent component onto a form, and using the Properties window to create an event handler.

Alternatively, for non-Visual Studio environments, or when using a component as a reference, you have to “wire-up” events to an “event handler” by adding the code yourself. The following C# code snippet shows how the Visual Studio wires up an event handler. You can use the same technique in any development environment:

[C#]
agent1.GetMessageReceived += 
        new Dart.PowerSNMP.MessageEventHandler(agent1_GetMessageReceived);

There are three kinds of events you may encounter when using the Manager and Agent components:

  1. Message Received Events. Agents never know when a request message might arrive, so this event is raised for any request. Managers never know when a response to an asynchronous request or a trap/notification might arrive, so message events are designed to be raised whenever an asynchronous message is received from the network. NOTE: These events are not raised for responses to a synchronous blocking request such as Manager.GetResponse().
  2. Authentication Events. Agents can have SNMP version 3 discovery and password events raised. This informs the application that an SNMP version 3 manager is attempting to communicate and authenticate.
  3. Exception Events. It is possible that received messages cannot be decoded or decrypted. This exception is raised when an unexpected condition is seen while processing a received packet on an IO completion thread.

You will probably need to perform some event processing, depending upon the complexity of your application.

 

In This Section

Overview
This topic provides an overview for using PowerSNMP for .NET.
Placing Components on a Form
This topic demonstrates how to create and use the components using Visual Studio .NET.
Creating Components Dynamically
This topic demonstrates how to add a component as a reference using Visual Studio .NET.
Synchronous vs. Asynchronous Use
This topic discusses the benefits and uses for synchronous and asynchronous methods.
Using Events
This topic discusses how to use events with the component, both using Visual Studio .NET and in other environments.
Using Components without Visual Studio
This topic discusses using the components in an environment other than Visual Studio.
Parsing MIB Files
This topic discusses the classes generated when parsing MIB files.
Namespace and Class Hierarchy
This topic discusses the namespace and class hierarchy under Dart.PowerSNMP.

 

 

 


Send comments on this topic.

Documentation version 1.2.0.0.

© 2008 Dart Communications.  All rights reserved.