473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Event Order

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?

May 28 '07 #1
3 1436
Why not just call the two methods you want to execute as Subs
from a single event handler?

On 28 May, 16:57, "Peter" <star...@hotmail.comwrote:
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?

May 28 '07 #2
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.

"Peter" <st*****@hotmail.comwrote in message
news:uZ******************@newsread1.news.pas.earth link.net...
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?

May 28 '07 #3
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.

"Andrew Taylor" <an***********@cantab.netwrote in message
news:11*********************@p47g2000hsd.googlegro ups.com...
Why not just call the two methods you want to execute as Subs
from a single event handler?

On 28 May, 16:57, "Peter" <star...@hotmail.comwrote:
>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?

May 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Amir Hardon | last post by:
I am dynamically adding rows to a table, and each row have a button which removes it. I have successfully implemented this for mozilla but I'm having troubles with IE, here is how I did it: ...
4
by: Dave H | last post by:
I originally posted a message "Getting the current cursor position using clientX,clientY" in which I hypothesised that the problem I was having was related to event handler execution order. I am...
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
5
by: Sergey Atun | last post by:
Hi, I inherited form and I writed it's load event: public class frmBase: System.Windows.Forms.Form { .... private void frmBase_Load(object sender, System.EventArgs e) { MessageBox.Show("this...
3
by: serge calderara | last post by:
Dear all, I am trying to understand postack event ordering. for that I have a web form with a text box, listbox and button server controls. Then I add a response.write in eaxh control event...
4
by: Girish | last post by:
Im trying to create a grid within a grid programmatically. Ive been successful in doing this but I need the embedded grid to fire its ItemDataBound event so I can handle it. The event does not seem...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
11
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session...
3
by: Bruce HS | last post by:
When I raise an event in an ancestor, the event fires first in the ancestor, then its descendant, and then in the descendant's descendant. I would like the descendant's descendant to fire first...
4
by: eggie5 | last post by:
I have this even handler (using prototype.js): showCommentsLinks.observe('click', function(event) { alert('hi') }); It's attaching to a link element: <a id="showCommentsLink"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.