View Single Post
Old 07-10-2006, 12:55 PM   #1 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
VB.NET 2005 Event Handling

I'm working on a small program to integrate alerts from one, into the other. So far I'm able to get everything to work, except for event handling. I'd like to receive event notifications asynchronously from program A, and send that alert message off as a TCP packet to program B.

I'm able to connect to the daemon process for program A, but either I'm not receiving alerts, or I didn't setup event handling right. Here is the relevant code:

Code:
    Private mGateway As IGateway
    Private mAlertEventHandler As AlertEventHandler
    Private mAlertEventImageHandler As AlertWithImagesEventHandler

    Private mAlertCount As UInteger = 0
    Private connectTime As UInteger = 0

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mGateway = ObjectVideoClientFactory.GetGateway()
        mAlertEventHandler = New AlertEventHandler(AddressOf OnNewAlert)
        mAlertEventImageHandler = New AlertWithImagesEventHandler(AddressOf OnNewAlert)

    End Sub

    Private Sub OnNewAlert(ByVal sender As Object, ByVal e As ObjectVideo.ClientSDK.AlertEventArgs)
        Dim alert As ObjectVideo.ClientSDKCommon.Alert = e.ReceivedAlert

        mAlertCount = mAlertCount + 1
        MsgBox("Alert #" + mAlertCount + " " + alert.Message)

    End Sub
__________________
Current Project
Redline is offline   Reply With Quote