Results 1 to 3 of 3

Thread: Event not raised in client

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 1999
    Location
    Suwanee, Ga, USA
    Posts
    21

    Event not raised in client

    I have a scenario that falls under the MSDN description of "something interesting has happened and the client app needs to know".

    I have an Ax.dll with one class in it, that governs all data access to a database. There is a method, that records operator actions into a log table. After each entry is made into the log table, this class calculates whether or not the log is 90% full. Like so:

    ' start log calc
    lngSize = GetEventLogSize 'get latest size
    lngUsed = GetEventLogNoRows 'get latest no. used rows

    'Check for 90% and raise event
    If (Abs((lngUsed / lngSize) * 100) > 89) Then
    RaiseEvent LogTableNearCapacity
    ' end log calc

    The application is an MDI app, and I create an instance of this DataMgr in the Form_Load event of the MDI form. My thought is since this form is always open, why not have him listen for the event. After re-reading in my VB Programmers Guide, events are anonymous broadcasts. If you are listening you can react to the event. So I have declared an object variable like so:

    ' Gen Dec Section
    Private WithEvents oDataMgr As NTCIPDataMgr.DataMgr
    ' create an instance in the Form_Load event
    Set oDataMgr = New NTCIPDataMgr.DataMgr

    Then sit back and wait, and when I hear the warning cry do:

    Private Sub oDataMgr_LogTableNearCapacity()
    EventLogWarning.Show
    End Sub

    I know the event is firing because I had the dll write to a text file that it performed the calculation and raised the event. Further since an event is a brodcast to the world, I thought I would place a second withevents object variable on one of the child forms to see if the event is raised there. No luck.

    Any thoughts?

    Thanks
    Kevin

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    An event is not exactly cast to the world. Events are instance specific so unless the withevents variable is set to the same instance as the one in the MDI form it will NOT recieve events for it.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 1999
    Location
    Suwanee, Ga, USA
    Posts
    21
    Edneeis

    Thanks for the reply, you could not be more correct. I just stumbled upon this about five minutes ago, and was going to write:

    "Never mind figured it out"

    This opens up some interesting scenarios.

    Thanks
    Kevin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width