Event Order

P

Peter

Hi,

I have two different methods that need to be executed when one event is
raised. The general way I've done this is to attach the same handle to both
methods, as follows.

Public Sub Method1 (ByVal sender as Object, ByVal e as EventArgs) Handles
Control.Event1
'code
End Sub

Public Sub Method2 (ByVal sender as Object, ByVal e as EventArgs) Handles
Control.Event1
'code
End Sub

But I need to ensure that Method1 is executed before Method2. How can I do
this? I thought that changing their order in code would work --- and it did
in one instance --- but in another, Method2 is executed first. How does
VB.NET decide what order it does these things in?
 
A

Andrew Taylor

Why not just call the two methods you want to execute as Subs
from a single event handler?
 
M

Miro

I have read in the doc's that the "Order" of which multiple events for the
same "handles" is unknown.

I would create 2 subs - and call them one after the other properly.

M.
 
P

Peter

That might work... I might have to do some fancy select cases for it though,
as in my actual code, one method has about 25 handlers attached to it, but
each of the handlers is also individually attached to one of 25 subs. I was
thinking of maybe calling the second method from the first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top