473,699 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Correct use of dispose

Hi,
I have a class with a handle to a window and a handle to its icon (if
it has one).

What do i need to do to correctly free these resources when my class is
disposed?

Cheers,
James.

Jan 22 '07 #1
2 1382
James,

See "Implementi ng a Dispose Method" in MSDN.

http://msdn2.microsoft.com/en-us/library/fs2xkftw.aspx

Brian

pigeonrandle wrote:
Hi,
I have a class with a handle to a window and a handle to its icon (if
it has one).

What do i need to do to correctly free these resources when my class is
disposed?

Cheers,
James.
Jan 22 '07 #2
That'll clean itself up, you dont need to do anything.

you only need to put code in dispose to free up external resources used by
the form or class.

"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
Hi,
I have a class with a handle to a window and a handle to its icon (if
it has one).

What do i need to do to correctly free these resources when my class is
disposed?

Cheers,
James.

Jan 22 '07 #3

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

Similar topics

9
1511
by: kjon | last post by:
I always dispose any object with the following: If not (obj1 is nothing) then obj1.dispose Now I wonder if that is the correct way of disposing an object? Should I use obj1 = Nothing after the dispose? Pls advice. Thanks.
3
1499
by: Marius Rus | last post by:
I have a project in C# that do the followings: From an csv text file it is taking datas and inserted into an paradox database. My problem it is that when writing into the paradox database it is writing two times same datas instead of course one time. Could be a hel please?
1
1760
by: Flix | last post by:
When making c# programs, I usually write code like this: SomeType myType=null; void Init() { myType=new SomeType(); }
6
1213
by: Rob Meade | last post by:
Hi all, Ok - I've used the word gramatically - which I'm sure is incorect, however I mean when VS2005 lists "warnings" like this one: Warning 1 Variable 'Command' is used before it has been assigned a value. A null reference exception could result at runtime. Warning 2 Variable 'Connection' is used before it has been assigned a value. A null reference exception could result at runtime. Warning 3 Variable 'Command' is used before it...
2
2938
by: Julio Allegue | last post by:
I am getting the wrong Count(*) on vb.net using the ExecuteScalar . It returns all the rows. It doesn't seem to look at the WHERE clause. At the same time, I am getting the correct count on "SQL Enterprise Manager" or "SQL Query Analyser" using the same SQL statement. Thanks in advance. Julio. Here is the SQL statement plus the source to the GetNumOfRow sub.
0
1651
by: Atara | last post by:
regarding the answers I got from the thread "Does each "New" needs a corresponding "Dispose" " (http://www.developersdex.com/vb/message.asp?p=&r=3582570&page=2) I have some questions: Till now, when I used dynamicCreatedControls with 'AddHandler', I wrote the 'RemoveHandler' code in my function that was called from the automaticGenerated Dispose function. (I have added example at the end of this message. )
3
1324
by: Chris | last post by:
I am just wondering if I did this the best way possible. I needed to add a double boarder around a label box. So I made a pen in the class, and do the drawing of the rectangles in the onpaint method. Did I do the disposal right? Is there a better way to do this? Thanks Chris Public Class ErrorMessageBox Inherits Label
7
1292
by: garyusenet | last post by:
Hi I have finally made progresss with my use of the open file dialog box! I have now made my own method that opens the dialog box and returns the file selected. Can you please have a quick look at the following code and tell me if what I have done is correct and good code. Thankyou very much : -
2
1227
by: Rob Meade | last post by:
Hi there, I have my own "way" I guess of coding, like we all do, whilst I try to maintain consistency throughout my own applications I often wonder whether there are better ways of doing things...since I started using Visual Studio 2005 I've been quite pleased with the messages it gives you when you make mistakes, and its underlining of unused variables and so on... One thing that, not so much puzzles me, but makes me think over and...
9
3987
by: seep | last post by:
hi i m finding following error on the code that i wants to use to get all record from table via store procedure with paging. the error is : Input string was not in a correct format. after a hectic struggle still i dont know 1--who can i solve it and 2--where should i have to place the function GETDATA . who is it possible to keep all the functions in a separate file and to call that file in required page. here is the...
0
8685
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, 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...
0
8613
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,...
0
9172
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, 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...
1
8908
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,...
0
8880
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 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...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
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...
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
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.