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

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 2116
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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,...

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.