Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
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
Old 07-10-2006, 01:40 PM   #2 (permalink)
SeyelentEco
Registered User
 
Join Date: Jul 2006
Posts: 14
SeyelentEco is on a distinguished road
You'll probably need to post more code.
SeyelentEco is offline   Reply With Quote
Old 07-10-2006, 01:59 PM   #3 (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
There isn't really any more code. Not any more that is relevant anyway. This is the connect code used to connect to the daemon

Code:
    Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click
        If mGateway.IsConnected Then Return
        Me.Cursor = Cursors.WaitCursor
        Try
            mGateway.Connect()
        Catch ex As Exception
            lblConnectStatus.Text = "Error in Connection Process"
            MsgBox(ex.Message)
        End Try

        If mGateway.IsConnected Then
            lblConnectStatus.Text = "Connected to Daemon"
            timerOne.Enabled = True
        Else
            lblConnectStatus.Text = "Could not connect"
        End If
        Me.Cursor = Cursors.Default
    End Sub

Really though, all I need is to find out if I setup event handling properly. I've never needed to write code for event handling in any language, so I really just winged it...
__________________
Current Project
Redline is offline   Reply With Quote
Old 07-10-2006, 02:02 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
question: why are you using vb and not c#? .. just curious cause i didn't think you had a vb background and c# would feel more natural with a php background.
__________________
Mike
sde is offline   Reply With Quote
Old 07-10-2006, 02:06 PM   #5 (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 was one of the first languages I learned, but that was back in my freshman year of highschool.

I decided on VB over C# because I wasn't quite understanding a lot of the syntax of C#. I suppose I could take another look at it though
__________________
Current Project
Redline is offline   Reply With Quote
Old 07-10-2006, 04:05 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
yeah, definately take another look at it. it is a c-based language, so it will be a lot little like PHP and Javascript.

it's strictly typed, so you do need to get used to declaring what type of variable you are creating.

it's using the same .NET objects that you would use in VB.NET, but the language itself was written for .NET, so you will never get caught in an instance where you are using legacy code which I think VB.NEt still supports.

i think the job market for c# is a little better as well. another good thing to have on the resume.
__________________
Mike
sde is offline   Reply With Quote
Old 07-10-2006, 04:25 PM   #7 (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
Do you know of another good place for tutorials on C#? The ones here were helpful, but I could use a few more if you know of some other sites offhand
__________________
Current Project
Redline is offline   Reply With Quote
Old 07-11-2006, 12:13 PM   #8 (permalink)
SeyelentEco
Registered User
 
Join Date: Jul 2006
Posts: 14
SeyelentEco is on a distinguished road
Yeah, I'm a C# developer myself, and the event handling looks okay, but I can't be 100% sure because VB.NET might do some stuff different. The thing is, I don't see how the event "OnNewAlert" is ever going to fire. I don't see what code might trigger that event.
SeyelentEco is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Article: Mimicking VB6 Control Arrays in VB.NET sde Code Newbie News 2 08-07-2007 11:08 PM
Combobox Glitch in VB.NET Joel Egghead MS Technologies ( ASP, VB, C#, .NET ) 0 10-20-2005 10:20 AM
EnterpriseDB 2005 Wins Best Database Award at LinuxWorld technobard Code Newbie News 2 09-06-2005 07:41 PM
Hitcounter problem sarah31 PHP 17 06-22-2005 01:58 PM
perl bot (learning) revolution All Other Coding Languages 15 10-21-2004 12:43 PM


All times are GMT -8. The time now is 04:32 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting