The trace output from the ASP.NET page does not display any information pertaining to
this event, because it fires after Render executes, but we can use the debug stream output from
the Output window when debugging the web form in Visual Studio to see the result:
Lifecycle: Init Event.
Lifecycle: Track ViewState.
Lifecycle: Load Event.
Lifecycle: PreRender Event.
Lifecycle: Save ViewState.
Lifecycle: Save ViewState.
Lifecycle: Render Event.
Lifecycle: Unload Event.
Lifecycle: Dispose Event.
Dispose Method
Dispose is the recommended location for cleaning up resources. Implementing a Dispose
method is recommended in .NET Framework programming when unmanaged resources (such
as a connection to SQL Server) are acquired by a control and need to be safely released within
the garbage collection architecture. The pattern is based on the IDispose interface that gives a
way for clients to tell an object to clean up its unmanaged resources:
Interface IDispose
{
void Dispose();
}
Once a client is finished working with an object, the client notifies the object that it is
finished by calling the object??™s Dispose method. This gives the object immediate confirmation
that it can clean up its resources instead of waiting for its Finalize method to be called during
garbage collection.
Pages:
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353