473,473 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

static IDisposable objects

I was recently looking through some code in a commercial product and noticed
a few places where they stored cursors and icons in static objects.

I would like to do something similar where I load two bitmaps in a static
constructor and store them as static members of a class.

My question is, what about IDisposable? There doesn't seem to be any way to
call it.

In my particular case, this is for a custom control and the bitmaps are tiny
(7x4 pixels). Is this considered an acceptable programming practice? I
assume this stuff will get cleaned up with the Finalize() method is called
on the bitmaps. I'm just curious if it's considered acceptable.

Pete
Nov 16 '05 #1
2 2118
Hello

It is acceptable if you use the object frequenly in the application, you
want the object to live until the program ends.

Best regards,
Sherif

<pd******@hotmail.com> wrote in message
news:5e******************************@news.meganet news.com...
I was recently looking through some code in a commercial product and noticed a few places where they stored cursors and icons in static objects.

I would like to do something similar where I load two bitmaps in a static
constructor and store them as static members of a class.

My question is, what about IDisposable? There doesn't seem to be any way to call it.

In my particular case, this is for a custom control and the bitmaps are tiny (7x4 pixels). Is this considered an acceptable programming practice? I
assume this stuff will get cleaned up with the Finalize() method is called
on the bitmaps. I'm just curious if it's considered acceptable.

Pete

Nov 16 '05 #2
Hello

It is acceptable if you use the object frequenly in the application, you
want the object to live until the program ends.

Best regards,
Sherif

<pd******@hotmail.com> wrote in message
news:5e******************************@news.meganet news.com...
I was recently looking through some code in a commercial product and noticed a few places where they stored cursors and icons in static objects.

I would like to do something similar where I load two bitmaps in a static
constructor and store them as static members of a class.

My question is, what about IDisposable? There doesn't seem to be any way to call it.

In my particular case, this is for a custom control and the bitmaps are tiny (7x4 pixels). Is this considered an acceptable programming practice? I
assume this stuff will get cleaned up with the Finalize() method is called
on the bitmaps. I'm just curious if it's considered acceptable.

Pete

Nov 16 '05 #3

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

Similar topics

26
by: codymanix | last post by:
Last night I had several thought about RAII and want to discuss a bit. Why doesn't CSharp support destructors in structs? Wouldn't that make RAII possible like in C++? When the struct goes out of...
6
by: Dolphin White | last post by:
For example, I allocate some unmanaged resources in the static constructors, then how can I properly release the resource before the application exit? thx!
5
by: jim | last post by:
Why was a destructor (finalizer) included in the syntax of C# if implementing IDisposable is the sure way to release resources held by a class? If you were doing a language from scratch would you...
0
by: | last post by:
I was recently looking through some code in a commercial product and noticed a few places where they stored cursors and icons in static objects. I would like to do something similar where I load...
4
by: Rick | last post by:
Hello, Below I create a static instance of an object, works well. public static BasicCounter GlobalCounter = new BasicCounter("GlobalCounter"); private void Page_Load(object sender,...
10
by: Dennis | last post by:
VB.Net Documentation for implementing IDisposable has: Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean) If disposing Then ' Free other state (managed objects). End If...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
6
by: Water Cooler v2 | last post by:
I heard from someone that we must not implement IDisposable for all classes. Can someone please tell me: 1. the reason why we must not implement IDisposable for all the classes we write. 2....
47
by: Hilton | last post by:
Hi, I'm sure I'm simplifying things here, but how about if the GC did this to objects that implement IDisposable: 1. Always Generation 1 (I think that is the correct name) 2. Get aggressive...
3
by: Paul | last post by:
Hi all, I currenty have a datalayer and have decided to impliment IDisposable with it. The data layer contains a number of objects which I can call dispose on, but i'm not too sure if you need...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
1
isladogs
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.