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

event subscription question

lets say i have an object with a bunch of events called ObjectA.

i subscribe to ObjectsA events with ObjectB methods

I set ObjectA to null.

what happens to my subscriptions?

Will ObjectA get garbaged collected?

If I set ObjectA to another object of the same type, will the subscriptions
switch?

Thanks in advanced!

Dan
Nov 15 '05 #1
1 1225
Dan H. <Da********@NO.comcast.SsPpAaMm.net> wrote:
lets say i have an object with a bunch of events called ObjectA.

i subscribe to ObjectsA events with ObjectB methods

I set ObjectA to null.

what happens to my subscriptions?
Nothing - if the object is garbage collected, then the delegates will
become eligible for garbage collection too.
Will ObjectA get garbaged collected?
Only if there aren't any other references to the object.
If I set ObjectA to another object of the same type, will the subscriptions
switch?


No.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

3
by: Max A. Bündchen | last post by:
My enterprise is a Registered Microsoft Partner and we would to acquire a MSDN Universal subscription under the Empower ISV Program to start a new project in .Net (today we dev under VFP 7). ...
3
by: Alex K. | last post by:
Hi all I have a class MyClass that exposes event A. Inside the class, I need to catch the moment when some other class subscribes to the event A. In other words, when some other class executes...
0
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
2
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
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...
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...
13
by: dmeglio | last post by:
Hello, I'm aware that when an EventHandler is created, it creates a reference to the object, therefore preventing GCing. Therefore, I've been implementing IDisposable in my controls to...
10
by: pedrito | last post by:
I have a library I'm using that has a lapsed listener issue. I figured I'd just sneak in and do the unsubscription myself since I don't expect it to be fixed any time soon. So, I have the...
3
by: Curious | last post by:
Hi, I have a program that gets the prices of stocks in real-time. The program consists of the following key components: // Constructor public GetRealTimeStockPrice() { // Step 1
11
Dheeraj Joshi
by: Dheeraj Joshi | last post by:
I have been trying to register a permanent event consumer in a remote machine, i am able to register for an event, but when the event occurs in remote machine it wont forward back the response... ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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...

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.