Using vs 2003, vb.net
It is not clear from the documentation, but it appears that a raised event
will traverse up the call stack upwards until it reaches its handler. Is
this correct? See the code snippet below. The event raised in sub1 or
class three will be caught in Class1 event handler (I know below is not
syntactically correct, but you get the idea).
Class 1 '------------------
friend Class2 as Class2x
Sub TestEvent_Event Handler Handles TestEvent
' raised event in class 3 caught here
end sub
' call something in class 2
end class
Class2 '------------------
friend Class3 as class 3x
Call Sub1 in class3
end class
Class 3 '------------------
Event TestEvent
Sub 1
RaiseEvent TestEvent
end sub
End class
please advise.
Bob Day 5 1856
Hi Bob,
Thanks for using Microsoft MSDN Managed Newsgroup. My name is Gary, and I
will be assisting you on this issue.
Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
-------------------- It is not clear from the documentation, but it appears that a raised event will traverse up the call stack upwards until it reaches its handler. Is this correct?
No, when you raise an event you just en up calling the list of handler
methods sequentially. There's no stack walking going on.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Whats the practical difference? If the handler is 3 levels up from where
the event was raise, it will be caught 3 levels up from where the event was
raised. Is this not the same as traversing the call stack up?
On a related mater, if multiple threads call the instantiated class that may
raise the same event, and all threads have the same handlers 3 levels up,
only the handler that will be trigger is the one that instantiated the
class, correct? Certainly handlers in other classes or threads would not be
triggered. I think the answer is yes - it would follow the stack back up to
its handler, even if there were identical handlers in other classes..
Your thoughts.
Thanks!
Bob Day
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:O5******** ******@TK2MSFTN GP10.phx.gbl... It is not clear from the documentation, but it appears that a raised
eventwill traverse up the call stack upwards until it reaches its handler. Is this correct?
No, when you raise an event you just en up calling the list of handler methods sequentially. There's no stack walking going on. Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Bob,
Are you confusing RaiseEvent with Throw exception?
As Mattias stated RaiseEvent does NOT tranverse stack frames, it calls each
handler added to the Event with AddHandler or Handles in turn, then returns
you to the current stack frame.
Throw exception will traverse up the call stack until a Catch block is
found.
From you description it sounds like you are talking Throw exception, while
your sample is (attempting) to show RaiseEvent.
Hope this helps
Jay
"Bob Day" <Bo****@TouchTa lk.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Using vs 2003, vb.net
It is not clear from the documentation, but it appears that a raised event will traverse up the call stack upwards until it reaches its handler. Is this correct? See the code snippet below. The event raised in sub1 or class three will be caught in Class1 event handler (I know below is not syntactically correct, but you get the idea).
Class 1 '------------------ friend Class2 as Class2x Sub TestEvent_Event Handler Handles TestEvent ' raised event in class 3 caught here end sub
' call something in class 2
end class
Class2 '------------------
friend Class3 as class 3x
Call Sub1 in class3
end class
Class 3 '------------------
Event TestEvent
Sub 1
RaiseEvent TestEvent
end sub
End class
please advise.
Bob Day
Thanks, that was very helpful.
Bob Day
"Bob Day" <Bo****@TouchTa lk.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Using vs 2003, vb.net
It is not clear from the documentation, but it appears that a raised event will traverse up the call stack upwards until it reaches its handler. Is this correct? See the code snippet below. The event raised in sub1 or class three will be caught in Class1 event handler (I know below is not syntactically correct, but you get the idea).
Class 1 '------------------ friend Class2 as Class2x Sub TestEvent_Event Handler Handles TestEvent ' raised event in class 3 caught here end sub
' call something in class 2
end class
Class2 '------------------
friend Class3 as class 3x
Call Sub1 in class3
end class
Class 3 '------------------
Event TestEvent
Sub 1
RaiseEvent TestEvent
end sub
End class
please advise.
Bob Day This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Al Christoph |
last post by:
I have a program that mixes wizard like behavior with random access to the
various dialogs in the wizard. I do this by having each step map to a
toolstripmenuitem. Users can randomly choose the menu item and get the
corresponding dialog. Alternatively at the completion of each dialog, I can
"click" on the menu item and cause the appropriate dialog to come up. It
works rather well but the way I've done it is a horrible kludge. I even left...
|
by: Jon Davis |
last post by:
The garbage handler in the .NET framework is handy. When objects fall out of
scope, they are automatically destroyed, and the programmer doesn't have to
worry about deallocating the memory space for those objects. In fact, all
the programmer has to worry about is the total sum of objects loaded into
RAM at any known point. Memory leaks are not a problem.
.... So one would like to think. The reality is that delegates and event...
|
by: Rhy Mednick |
last post by:
I have a class (let's call it ClassA) that I've written which has events.
In another class (let's call it ClassB) I create a collection of ClassA
objects. In a third class (ClassC) I create a reference to some of the
ClassA objects created in ClassB. In ClassC I hook into the ClassA events
with a foreach loop so that I hook each object. The code is something like
this:
class ClassC {
void SomeMethod()
{
foreach (ClassA item in...
|
by: Natalia DeBow |
last post by:
Hi,
I am working on a Windows-based client-server application. I am involved in
the development of the remote client modules. I am using asynchronous
delegates to obtain information from remote server and display this info on
the UI.
From doing some research, I know that the way my implementation works today
is not thread-safe, because essentially my worker thread updates the UI,
which is BAD. So, here I am trying to figure out how...
|
by: Stampede |
last post by:
Hi guys 'n' girls,
I want to use callback methods when using BeginInvoke on some events. So far
no problem, but know I thought about what could happen (if I'm not completly
wrong).
Lets say an event is triggerd with BeginInvoke and a callback funktion which
is part of the instanze which is also holding the event. So the call looks
something like this:
public class MyClass {
| |
by: Nicky Smith |
last post by:
Hello,
I'm studying a book on VB.net Win apps, and I'm reading a section on
events and delegates and raising events.
Is it just me, or is this not just subs dressed up as something else?
I mean, for one, delegates point to subs, so when you call a delegate,
why not just call the sub dierectly and not bother adding the extra
code involved adding the delegate?
|
by: Nathan Sokalski |
last post by:
I have a very simple UserControl which contains an Image and a Label, which
I use to display an image with a caption. I am using this control inside a
DataList, setting the two Public variables using attributes in the *.aspx
page. Everything displays great for the initial load, but whenever I try to
add or delete an item (I have controls to do this on the page), it does not
seem to be recieving any values for the public variables. Here is...
|
by: Steve Hershoff |
last post by:
Hi everyone,
I've got a strange one here. There are two datagrids on my page, one nested
within the other. I'll refer to them as the topmost and secondary
datagrids.
In the topmost datagrid's OnItemDataBound() method we check for the row in
which it's appropriate to add the secondary datagrid. Exactly one row in
the topmost grid will contain the secondary grid.
|
by: JohnM |
last post by:
Hi there,
Are there any specific rules or best-practices I should be aware regarding
events and the threads they're fired on. Object 1 can be created on thread 1
for instance and an event then registered with it on thread 2. Object 1
might then fire the event on thread 3 and the event might later be
deregistered on thread 4. Are there any inherent problems with these (and
other) scenarios so long as the event handler is properly dealing...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |