|
-
Aug 21st, 2002, 06:41 AM
#1
Thread Starter
Junior Member
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
-
Aug 21st, 2002, 10:13 AM
#2
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.
-
Aug 21st, 2002, 11:16 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|