Re: Controling Event Sequencing...
- From: "Claes Bergefall" <louplou@xxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 16:28:14 -0400
Did you use BeginInvoke (Invoke won't work)? What are you doing in your
methods? Can you show the code you're using to test this?
It works fine for me. Maybe you have a different definition of "after the
event is fired"...
The Click event is fired in response to a WM_COMMAND message that gets sent
to the message queue by Windows. When you call BeginInvoke as shown below,
the framework will post a message (using PostMessage) to the message queue
and immediately return. This message will be placed last in the queue, so
when the framework eventually gets to it, the Click event (and the
WM_COMMAND message that triggered it) have long since been completed. The
event can't be any more finished than this, so not sure what you're after.
/claes
"jeff" <jhersey at allnorth dottt com> wrote in message
news:eoE4RV7mGHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
Does not work...
the method invoker ... simply calls the method and executes it within the
same event ... does not execute after the event is fired....
Oh well...from the overwhelm responce and input, I assume this is not
something done with this language ...I will stop beating my head against
the wall and try to work around it ...
thanks.
Jeff.
"Claes Bergefall" <louplou@xxxxxxxxxxxxx> wrote in message
news:OcOAsnrmGHA.3600@xxxxxxxxxxxxxxxxxxxxxxx
You can use a BeginInvoke to invoke a method asynchronously. What this
really does is post a message to the message queue and eventually calls
your method. That way your OnClick event handler will be finished before
the PostClick stuff runs. Something like this (assumin you inherit
Button)
Protected Overrides Sub OnClick(...)
MyBase.OnClick(...)
Me.BeginInvoke(New MethodInvoker(AddressOf OnPostClick))
End Sub
Private Sub OnPostClick()
...
End Sub
This won't help you with PreClick though. Not sure how to solve that (if
you still need it)
/claes
"jeff" <jhersey at allnorth dottt com> wrote in message
news:%23pxwYkhmGHA.3980@xxxxxxxxxxxxxxxxxxxxxxx
Thanks, unfortunately this does not solve my problem...another
example...
the problem is ... the initial 'click event' will not be completed
before the OnPostClick event is fired / executed ... that is the problem
... i need the OnPostClick event fire after the OnClick event is
completely finished ... I need some way to put to the OnPostClick in the
windows event queue and have it execute AFTER the OnClick in completely
done ... at all levels...
Another example...
say you have a custom control...with an event ... ItemChanged ... the
control exposes this event to the programmer to allow him / her to
capture and code on it according ... however once the control fires this
event - the ItemChanged -, it continues processing the rest of 'its'
system events to complete the ItemChanged action ... say some internal
stuff ... writes data to a buffer / file and so on ... These events will
happen right after the programmer exposed Itemchanged, as the control
has already put them in the windows event queue - ItemChanged for the
Programmer, ItemChanged Write to File (control event not exposed),
ItemChanged write to Buffer (control event not exposed) and so on ...
So, these system / control events will immidiately fire after the
programmer's - ItemChanged event ...
So, what I want to be able to do, is create a base class object for this
control ... myControl...
in the ItemChanged event I want to call / raise my own user event ...
ueMyEvent_AfterChange ... the purpose is so I know when the entire
ItemChanged event is completed and the data has been writen to the file
... or a buffer...or whereever...my event will be next...so, using the
event sequence from above...ItemChanged for Programmer, ItemChanged
Write to File (control event), ItemChanged write to buffer (control
event), and now my ueMyEvent_AfterChange fires.
Now, in my application, whenever I need this control or versions of
(descendants) ... I can use my custom event ueMyEventChanged to access
the information in the File / Buffer... because I know the control's
entire ItemChanged event has completed and MyEventChanged will not fire
until it is completely done. Simply calling the event inside the
Itemchanged event will not give me what I want ... I need someway to
tell vb to delay my custom event until the control's ItemChanged event
or or System OnClick of the button is completed and run it course ...
Does this make since...or sound a little stretched...
Jeff.
"Claes Bergefall" <louplou@xxxxxxxxxxxxx> wrote in message
news:eECBaCgmGHA.4992@xxxxxxxxxxxxxxxxxxxxxxx
Define when an event has completed (and when it begins).
The simplest solution is to do this:
Protected Overrides Sub OnClick(...)
OnPreClick(...)
MyBase.OnClick(...)
OnPostClick(...)
End Sub
Not sure if this meet your definition of completed though
/claes
"jeff" <jhersey at allnorth dottt com> wrote in message
news:OTVHSjVmGHA.2452@xxxxxxxxxxxxxxxxxxxxxxx
in addition....
I want to post the raise the event so that it will execuate after the
current system event has completed...
Jeff.
"jeff" <jhersey at allnorth dottt com> wrote in message
news:e68VpZVmGHA.4816@xxxxxxxxxxxxxxxxxxxxxxx
New VB user...developer...
Situation...simplified...
- I want to wrap a pre and post event around a system generated where
the pre-event will always execute before the system event and the
post event will always execuate after the system is completed...
- I want to wrap this functionality in a framework, so I could
possibly have 3 or 4 levels of inherited objects that need to have
these pre / post events executed before and after the system event is
starting and completed...
- basically, i want to be able to add a 'Post' event to the message
queue and have it executed after the system event is completed...
ie. button clicked ... post my event ... button done clicking, system
does what is does on a completed clicked ... my event that i posted
runs now...
Example...simplified...
- I want to build to custom class inherited from the common command
button.
- I want to add a 'pre-click' and a 'post-click' event to the buttons
click event ... and still allow the developer to use the clicked
event...
so ... on my base class object ...
I add to custom subs/functions/events...whatever you want to call
them to the control...
ue_PreClick()
ue_PostClick() ...
in the click event i call them by....Click Event...
ue_preClick(...) ... calls the User Event - Pre-Click for the
button...
POST ue_postClick() ... posts a User Event - Post-Click that will be
executed after the click event is completed...
Now, the sequence of events I am looking for is....
in any descendant class...if I code the pre-click event....the code
will execute before the click and postclick events...simple, this
works.
now, in any descendant class...i want the post-click event to fire
only when the Click event is completed for the button...
So, for example...
ButtonBaseClass...base object inherited from the windows controls
buttons ...
Add two functions...
uePreClick (arg...)
uePostClick(arg...)
Now, I inherit from this and create another button...
ButtonFirstChild
I place this code the the uePreClick
MessageBox.Show("Hello, I am in the PreClick Event")
I place this code in the uePostClick event ...
Messagebox.Show("Hello, I am in the PostClick Event")
and finalling, I put this code in the Clicked Event...system event...
Messagebox.show("Hello, I am in the Clicked Event")
So, when I click the button ... I want to see message boxes ...
PreClick...
Click...click is done...
PostClick...
So, my question is, is there anyway in the ancestor / parent / base
class to code it such that is will execute the events in this order
... I know I could code three custom events .... uePreClick ,
ueClick, and uePostClick ... and code accordingly, but what I am
after here is I want the uePostClick event to fire after the system
Click event has completed...
Is this possible in VB .Net....this is a technique I user with
Powerbuilder and it works just fine...unfortunately, I can see not
how to handle this is VB...and help of guidance would be great...
the Application.DoEvent will flush the message queue but it will not
complete the current event before calling the 'POSTED' event...what I
need is the current event to be done ... than the post event fired.
Any help would be greatly appreciated...
Thanks
Jeff
.
- References:
- Controling Event Sequencing...
- From: jeff
- Re: Controling Event Sequencing...
- From: jeff
- Re: Controling Event Sequencing...
- From: Claes Bergefall
- Re: Controling Event Sequencing...
- From: jeff
- Re: Controling Event Sequencing...
- From: Claes Bergefall
- Re: Controling Event Sequencing...
- From: jeff
- Controling Event Sequencing...
- Prev by Date: Re: a simply VB.net/ SQL SERVER question
- Next by Date: Re: DataGridView Question - VB.NET 2005
- Previous by thread: Re: Controling Event Sequencing...
- Next by thread: Re: button flash with red and white color
- Index(es):