473,395 Members | 1,554 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.

close dispose nothing

Can someone tell me
1)
Is there a difference between closing or disposing a reference data type

2)
about nothing

dim fr as form2
isnothing(fr) gives true

but

dim fr as form2
fr = new form2
fr.dispose
isnothing(fr) gives false

what means nothing?
Dec 7 '07 #1
7 1581
"andreas" <an*****@pandora.beschrieb
Can someone tell me
1)
Is there a difference between closing or disposing a reference data
type
Closing is not a default pattern. Disposing is, and it's described in the
Framework docs. Some classes might have a Close method, some are disposable,
some have both. Whether closing is the same as disposing depends on the
class. Look at the docs of the class. There is no general answer.
2)
about nothing

dim fr as form2
isnothing(fr) gives true

but

dim fr as form2
fr = new form2
fr.dispose
isnothing(fr) gives false

what means nothing?

Nothing means "no reference". A variable declared As Object or As a
reference type (classes are reference types), are pointers to an object. A
pointer is the address of the object in memory. If the variable is 0, it is
Nothing.

To compare reference, use the Is operator:

If a Is b Then 'True if both variables reference the same object

If a Is Nothing Then True if variable a is Nothing

Don't use the "IsNothing" function. Use the Is operator as shown because it
directly does what has to be done. The IsNothing function does the same, but
there's no need to call a function for this.

In your first example, "fr" is Nothing because you didn't assign anything,
so it's nothing if you check it. In the 2nd example, you assigned the
reference to an object (of type Form2), so it's not Nothing.
Armin

Dec 7 '07 #2
On Dec 7, 12:00 pm, "andreas" <andr...@pandora.bewrote:
Can someone tell me
1)
Is there a difference between closing or disposing a reference data type

2)
about nothing

dim fr as form2
isnothing(fr) gives true

but

dim fr as form2
fr = new form2
fr.dispose
isnothing(fr) gives false

what means nothing?
I would like add 1 more point to the other posters reply that when you
dispose an object, .Net framework says that is does not guarantee the
time of actual disposal.
This is so because the garbage collector runs randomly and is invoked
automatically when Memory is low.
Dec 7 '07 #3
"Cleaning Up Unmanaged Resources" (disposable pattern)
http://msdn2.microsoft.com/en-us/lib...w2(VS.90).aspx

which is a sub topic of: (Garbage collection)
http://msdn2.microsoft.com/en-us/lib...tx(VS.90).aspx

CLR memory management:
http://msdn2.microsoft.com/en-us/lib...3t(VS.90).aspx
Armin
Dec 7 '07 #4
Armin,

As I have the idea that by instance in AdoNet is the closde overriden by the
dispose, while the dispose is overridden with the close.

I think that it is at most places as it is about data.

Cor

Dec 8 '07 #5
Andreas,

I would ask this question in particular in the situation of the form in this
way.

Why is there a difference between IsNothing and IsDisposed.

While I write this you see probably already that there is a difference.

A form which IsNothing is has no reference anymore and a form which
IsDisposed does not exist anymore.

However it is cullprit, by just creating your form everytime New you are
maybe using some more nanoseconds, then the test you need if it still exist,
by showing it there will be used billions times more.

However you could have asked what is the difference between a String which
Is Nothing and a string which = Nothing.

The first is not instanced, while the second is empty. However, the second
instances direct the string and therefore it could have been before as well
a string which was not instances. (Because this is always Armins
speciallity: Correct me if I wrote this wrong Armin?)

Cor

Dec 8 '07 #6
"Cor Ligthert[MVP]" <no************@planet.nlschrieb
(Because this is
always Armins
speciallity: Correct me if I wrote this wrong Armin?)
I must correct you if you say that my speciality is always
to correct you. ;-)

(I can not contribute anything to the topic because I'm not sure what you
meant with your post)
Armin

Dec 8 '07 #7
On Sat, 8 Dec 2007 09:51:46 +0100, "Cor Ligthert[MVP]"
<no************@planet.nlwrote:
>Andreas,

I would ask this question in particular in the situation of the form in this
way.

Why is there a difference between IsNothing and IsDisposed.

While I write this you see probably already that there is a difference.

A form which IsNothing is has no reference anymore and a form which
IsDisposed does not exist anymore.
I haved to disagree with this. I don't see how it makes any sense to
say "a form which Isnothing". A reference can be Nothing, but not a
form.

A form which has been disposed but not yet garbage collected does
exist, perhaps not visually but certainly it exists as a structure in
memory.
>However it is cullprit, by just creating your form everytime New you are
maybe using some more nanoseconds, then the test you need if it still exist,
by showing it there will be used billions times more.

However you could have asked what is the difference between a String which
Is Nothing and a string which = Nothing.

The first is not instanced, while the second is empty. However, the second
instances direct the string and therefore it could have been before as well
a string which was not instances. (Because this is always Armins
speciallity: Correct me if I wrote this wrong Armin?)
I don't really understand what you are saying here, but it sounds
wrong to me. A reference to a string can be Nothing, in which case
there is no memory allocated for the string, or it can point to an
empty string, in which case there is memory allocated. To me "a
String which is Nothing", while worded oddly (because a string can not
be Nothing but a reference to a string can be) to me means a reference
is Nothing. "a string which = Nothing" also doesn't have much meaning
because a string can not be Nothing, only a reference to a string.

There is the oddity with the String class that lets a reference to a
string that contains Nothing be compared to an empty string without
trapping, but I don't think you are talking about that.
Dec 8 '07 #8

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

Similar topics

7
by: Willem van Rumpt | last post by:
Hi all, coming from an unmanaged programming background, I took my time to sort out the IDisposable and finalizer patterns. Just when I thought I had it all conceptually neatly arranged, the...
19
by: Nathan | last post by:
I know this has been asked previously, but I've run into a situation where I need to know the difference between close and dispose, and I can't get the information I need from msdn help or previous...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
8
by: Paul W | last post by:
Hi - in an asp.net application, how should I close out a sqlclient.connection? What combination and order of Conn.close conn.dispose conn=nothing Should I use? Specifically, is the...
2
by: Bert Szoghy | last post by:
Hello, I am missing something about Visual Basic .NET module variables and window close events. In the following code, after opening Form2 by clicking a button on Form1 and then closing...
3
by: Joris De Groote | last post by:
Hi, I use Adobe Acrobat to read tekst from PDF files. After that the file has been read, I move the file in a folder (using the date I got from the text I got from Acrobat). Now here is my...
3
by: Cylix | last post by:
Does anyone can explain the details between Connection.close Connection.dispose Connection = nothing If I just need to close the connection and release the memory, do I need to write all...
54
by: Zytan | last post by:
I have a log class that makes a synchronized TextWriter like so, in the constructor: StreamWriter sw = new StreamWriter(filename); tw = TextWriter.Synchronized(sw); In the destructor,...
3
by: =?Utf-8?B?UmljaA==?= | last post by:
Public Class MainForm Dim frm As DetailFrm '--frm is a Form Level variable Private Sub MainForm_Load(...) frm = Nothing .... End Sub Private Sub btnOpenDetail_Click(...)Handles btn.Click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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...
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,...

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.