.NET provides "finalize" method in which clean up our
resources.but this is always not good so the best is to
implement interface and implement the "Dispose" method
where you can put your clean up routines
Both are ways to destroy the object. By object i mean when
you have some unmanaged resources used in your class, you
have to make sure that you write the logic to destroy them
in the finalize() method. But this is the implicit way of
destroying the unmanaged resources, as finalize is called by
garbage collector when it find thats there is no reference
to this object from the stack.
There is an explicit way to destroy the unmanaged resources.
That is by implementing IDisposable interface. By
implementing this interface, ie you have to write the code
to destroy the resource in Dispose() method, you can call
the object to destroy itself when ever required in your code.
The GC call the Finalize() function automatically to destroy
the object called implicit destroy. when you want to destroy
a objects that you think no longer need and free it from
memory, then we will use the dispose function. For better
performance we will use the dispose function explicitly.
A Dispose() method is explicit, meaning you code Dispose()
up and explicitly call it in your application or system
code. A Finalize() method is implicit, meaning you code
Finalize() up but never actually call it — Finalize() is
called behind the scenes by the .NET GC mechanism.
The GC call the Finalize() function automatically to destroy
the object called implicit destroy. when you want to destroy
a objects that you think no longer need and free it from
memory, then we will use the dispose function. For better
performance we will use the dispose function explicitly.
when we write the destructor in c#,the runtime replaces the
destructor with the finalize method in IL code,so we dont
know at what time the destructor is called by the garbage
collector.so the finalizer is non deterministic.if we want
to do the garbage collection for unmanages resources,we
have to implement our own destructor or finlizer
method.but,the runtime will take two round trips to remove
those objects from the heap.if runtime calls the own
destructor,it will take onely one round trip.
to remove the unmanaged resources without the performance
issues,we have to inherit the System.Idisposable interface
and implement the Dispose() method.here one problem is
there,we have to write a code in a way that,the dsipose
method must and should execute.
for that reason we have to keep the dispose methos for the
objcets in the finally block.
problem with the dispose is that,some times because of
some problmes dispose() methos may not execute.
so the good practice is to use both to achieve the desied
performance.
Dispose() Method is used to release Unmanage Resources.
When Unmanage Resources are no longer in use and Referenced
and is called Manually.
and
Finalize() Method is similar to Dispose Method But it is
called by the Garbage Collector.
Finalize and dispose are used to clean the objects from
memory. But Finalize will be called based on the GC. If you
finalize any object that will be moved to Finalize queaue.
When the time of the round trip of the GC. It will remove
the objects from Finlize queaue.So,it will not destroy the
object immediately. Unless dispose method will remove the
object immediatley without considering the GC.
What is the result when the Web Form containing the
following line is complied and executed?
<asp:Button id=?thebutton? onClick=?theEvent? />
a) The button control is created; theEvent is the click
event handler.
b) Compiler error; the control must be set to runat=?server?.
c) Compiler error; onClick is not a valid attribute.
d) Runtime Exception; the control must be set to runat=?server?.
What are the types of assemblies and where can u store them
and how a private assembly is used only by a single
application, and is stored in that application's install
directory (or a subdirectory therein)?
After building the custom control, you test it by adding an
ASP.Net web application to the solution. You add a correct
<%@ Register %> directive and a proper declaration of the
control in the <asp:Form> tag to the Web Form, but when you
execute the application you get an error. What is the most
likely reason for the problem?
a) The custom control must be compiled first.
b) The web application must have a reference to the control
c) The custom control must be registered with windows first.
d) The assembly from the custom control is not in the
application?s bin directory.
What is the function of the CustomValidator?
a) It allows for custom C# client-side code to validate
entries in a control.
b) It allows for a custom mixture of validator controls to
use one central control for the display of messages.
c) It uses scripted client-side code to validate the entry
in a control.
d) It uses server-side code to validate the entry in a control.
I am using SQLServer 2005. I have one table called Drivers.
Every day thousands of records will be added in this table.
I have to show all these records in my GridView with out
applying ajax timer beacause we don't know
the time limit when the new record come to the table.
Sometimes it will add for 10 seconds some times 20 seconds.
There by Please try without using timer or any other
soultion apply for the table in sqlserver.
But, i want to see all records immediately when new record
comes in table. How?
Thanks in advance...
Ramesh