473,324 Members | 1,856 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,324 software developers and data experts.

event model question

If I have a routine that handles event A of class B coded in VB.Net
like:

Private Sub handleEventA Handles B.eventA
Debug.WriteLine("eventA handler for class B")
End sub
and then I perform the following three steps

1. Debug.WriteLine("step 1")
2. B.Setsomething=4 'this raises event A in class B
3. Debug.WriteLine("step2")
The output window in my IDE would show the following:

step1
eventA handler for class B
step2

My question is is this guaranteed, is this how the event model works,
or put anotherway, are the events guaranteed to be raised
synchronously?
Thank you
Colin
Nov 20 '05 #1
2 1237
"Colin McGuire" <co***********@lycos.co.uk> schrieb
If I have a routine that handles event A of class B coded in
VB.Net like:

Private Sub handleEventA Handles B.eventA
Debug.WriteLine("eventA handler for class B")
End sub
and then I perform the following three steps

1. Debug.WriteLine("step 1")
2. B.Setsomething=4 'this raises event A in class B
3. Debug.WriteLine("step2")
The output window in my IDE would show the following:

step1
eventA handler for class B
step2

My question is is this guaranteed, is this how the event model
works, or put anotherway, are the events guaranteed to be raised
synchronously?

Yes, events a raised synchronously, unless the documentation says something
else.
--
Armin

Nov 20 '05 #2
Colin,

To the best of my knowledge, events are handled on the same thread they have
been raised on. So, in a single-threaded application, events are handled
just in the same order they have been raised - since raising an event
actually leads to calling one or more delegates (i.e. callbacks) subscribed
to this event.

For multi-threaded applications, I suppose, the order is retained for each
of the threads.
So, in your example:
1. Debug.WriteLine("step 1")
2. B.Setsomething=4 'this raises event A in class B
3. Debug.WriteLine("step2")
You should always be getting the same output:

step1
eventA handler for class B
step2

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om... If I have a routine that handles event A of class B coded in VB.Net
like:

Private Sub handleEventA Handles B.eventA
Debug.WriteLine("eventA handler for class B")
End sub
and then I perform the following three steps

1. Debug.WriteLine("step 1")
2. B.Setsomething=4 'this raises event A in class B
3. Debug.WriteLine("step2")
The output window in my IDE would show the following:

step1
eventA handler for class B
step2

My question is is this guaranteed, is this how the event model works,
or put anotherway, are the events guaranteed to be raised
synchronously?
Thank you
Colin


Nov 20 '05 #3

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

Similar topics

3
by: Lachlan Hunt | last post by:
Hi, I've been looking up lots of documentation and trying to work out a cross-platform method of capturing a keyboard event and working out which key was pressed. From what I can find, there...
9
by: VK | last post by:
My original idea of two trains, however pictural it was, appeared to be wrong. The truth seems to be even more chaotic. IE implements its standard down-up model: any mouse event goes from the...
10
by: Noozer | last post by:
Is it possible to detect where on a page the click occurred when the OnClick event of the BODY tag is fired? Thx
1
by: Wavemaker | last post by:
I was wondering if there is a way to change the value of a control without triggering an event. The ComboBox control, for example, will trigger the SelectedIndexChanged event when its SelectedIndex...
6
by: Steve B. | last post by:
Is it good programming practice to call an event within an event? I'm I creating recursion somehow somewhere? Does an event (e.g. send, e) ever end? I'm sorry, I'm not sure I know what I mean,...
6
by: Tim | last post by:
Hi, I have a module that acts as a publisher of events. The clients subscribe for the events using the '+=' operator. Instead, I would like the clients to call a method like "RegisterForXEvent"...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.