|
Dispose is a method on an interface (IDisposable) that tells you that you can free up some resources. It is not guaranteed to be called, but can be called either explicitly via the MyObject.Dispose method, or implicitly when the instance has been wrapped in an using block, e.g.
using (SqlConnection conn = new SqlConnection())
{
..
} The finalizer is run by the garbage collector, so you have no idea when it will run (under normal conditions that is - it is possible to explicitly call a Finalizer, but this is generally bad practice). Now, if you implement IDisposable.Dispose() then it is normally good practice to suppress the Finalizer. This is done by calling the method GC.SuppressFinalize() in the Dispose method. To this end, I tend to write a message to the trace logs if I get into a Finalizer when I have a Dispose method. By doing this, I can see where I haven't freed up resources explicitly.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: To this end, I tend to write a message to the trace logs if I get into a Finalizer when I have a Dispose method. By doing this, I can see where I haven't freed up resources explicitly.
Now that is an excellent idea!
|
|
|
|
|
|
First of all, you generally don't want to write a finalizer unless you really need to. There are a lot of rules that should be followed in a finalizer and a lot of assumptions that can normally be made about the state of the objects and the runtime are not valid inside a finalizer. They add a cost to your object as well, even if the finalizer is never called.
That being said, as others have pointed out, Dispose is part of the IDisposable interface and helps implement the Dispose pattern. This pattern provides an explicit method for cleaning up resources.
A finalizer provides for implicit cleanup and, if your class has one, will be automatically called at some non-determistic time as part of the garbage collection process.
|
|
|
|
|
|
|
|
I have used Gios PDF .NET library for PDF creation. My requirement is that, i dont want to create new page evary time for new tables, i have to use 2 line break after each table in PDF Page. is it possible to write multiple tables on same PDFPage using 2 line break after each tables.(I want to avoid unnecessary spaces on PDFPage).
Please send me source code in C#.net, thanks in advance.
Thanks,
Sanjeev Ranjan
-- modified at 9:09 Friday 31st August, 2007
|
|
|
|
|
|
i have to pass the username name and password to another form using the query string.
Is there any way to encrypt the query string ? So that the data can we secured
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
This is never a good idea. Even with encrypted text, the query string is still going to be visible thereby allowing somebody else to steal and use the query string.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i know it will be visible , but the information will not be directly visible to others
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
As it is transmitted over a network it will be visible to others (packet sniffers etc). Never design security like this - especially as this info is text encoded.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
hello,
is there any specific control in asp.net which we can use somethign like in codeproject sections navigations menu in left corner which expands when we click a main category? please give me some idea about these.
aneef
|
|
|
|
|
The controls are availbe as part of ajax toolkit 2 such controls are
1) Accordance pane.
Live demo @ http://www.asp.net/AJAX/Control-Toolkit/Live/Accordion/Accordion.aspx
2) Collapsable panel
live demo @ http://www.asp.net/AJAX/Control-Toolkit/Live/CollapsiblePanel/CollapsiblePanel.aspx
This can be done using javascript as well as below.
Create a Div element like below.
[Create any clickable elmenet here which can call a javascript for eg:]
<a href ="javascript:return true" onclick="displayDiv();">Click here to expand</a>
<div id="Panel1" style="visibility:hidden;">
put your controls here.
<div>
Below is how the javascript function looks like
function displayDiv()
{
if(document.getElementById("Panel1").style.visibility == "hidden")
{
document.getElementById("Panel1").style.visibility = "visible";
}
else
{
document.getElementById("Panel1").style.visibility == "hidden"
}
}
Please rate the message if it helpe you
|
|
|
|
|
Hi,
I have the following code
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if(checktables.Checked == true)
{
int tables = Convert.ToInt32(txtqtables.Text);
listBox1.Items.Add(35 * tables);
}
}
If I click on my CheckBox, I want the number in the txtqtables.text to be multiplied by 35 and the results to be place in a listbox.
I am getting an error on "int tables = Convert.ToInt32(txtqtables.Text);"
Input string is not in a correct format.
Please help.
|
|
|
|
|
paullet wrote: I am getting an error on "int tables = Convert.ToInt32(txtqtables.Text);"
Input string is not in a correct format.
Then the value that is put in the text box is not an integer. You need to validate the contents of the text box first, then attempt to convert it. You can also use Int32.TryParse to attempt to convert it and return a boolean to indicate if the conversion succeeded.
|
|
|
|
|
Hi, if TextBox is empty or contains something that Convert does not recognize
you would get that exception.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi
I have an application where nodes in the tree view control represent property sheet
And each property sheet contains some controls like checkboxes, buttons and etcc…..
And these controls are rendered on to the property sheet when we select a node in the tree view control. Problem is when a particular property is containing more controls compared to the property sheet which was previously selected then rendering of the controls on the property sheet becomes dirty or does not draw correctly can u pls suggest me any solution for this problem?
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
Hi all,
Is there a way to select a row using the right click?
For instance, can one select a row using right click before the context menu pops up?
Thanx in advance
|
|
|
|
|
|
Thanx alot, this is exactly what I need!!!
BUT, the link http://msdn.microsoft.com/smartclient/community/wffaq/wf20.aspx#al3sfum0 is dead
|
|
|
|
|
Ok nvm guys, I got something http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=619907&SiteID=1
It is VB code, but easy to convert to C#. Thanx!
|
|
|
|
|
i think you dont need this link
the codes its in that link i gave you
Becoming Programmer...
|
|
|
|