H
hartley_aaron
Hi,
I was wondering if it were possible to add some code that would proceed
and/or follow the execution of each each event in the form and/or
application? The code would be the same no matter which event is being
called, so it would be ideal be able to write it only once, or at least
once for each form as opposed to writing it into each event in the
application.
In my situation, I need to deactivate a particular global class object
whenever an event is started and activate it again when event handling
code completes. In other words, I need to have the object turned off
when anything is happening.
As far as I know currently I would have to add the code to each every
event in my code and maintain that over time. For example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objMyObject.Enable = False
'do something
objMyObject.Enable = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
objMyObject.Enable = False
'do something else
objMyObject.Enable = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
objMyObject.Enable = False
'etc
objMyObject.Enable = True
End Sub
Maybe its just wishful thinking, but what I would like to have is
something like this (obviously wrong):
Private Sub UniversalEventHandler(ByVal objEvent As EventHandler,
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.All
objMyObject.Enable = False
objEvent.Invoke(sender, e)
objMyObject.Enable = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'do something
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
'do something else
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
'etc
End Sub
Does anyone have any ideas?
I was wondering if it were possible to add some code that would proceed
and/or follow the execution of each each event in the form and/or
application? The code would be the same no matter which event is being
called, so it would be ideal be able to write it only once, or at least
once for each form as opposed to writing it into each event in the
application.
In my situation, I need to deactivate a particular global class object
whenever an event is started and activate it again when event handling
code completes. In other words, I need to have the object turned off
when anything is happening.
As far as I know currently I would have to add the code to each every
event in my code and maintain that over time. For example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
objMyObject.Enable = False
'do something
objMyObject.Enable = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
objMyObject.Enable = False
'do something else
objMyObject.Enable = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
objMyObject.Enable = False
'etc
objMyObject.Enable = True
End Sub
Maybe its just wishful thinking, but what I would like to have is
something like this (obviously wrong):
Private Sub UniversalEventHandler(ByVal objEvent As EventHandler,
ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.All
objMyObject.Enable = False
objEvent.Invoke(sender, e)
objMyObject.Enable = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'do something
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
'do something else
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
'etc
End Sub
Does anyone have any ideas?