I. ihttpmodule Init () is executed only once:
The ihtttpmodule. INIT () method performs initialization operations when the application is started. Therefore, this method only needs to be executed once.
Therefore, the method called in this method will only be executed once (we can implement operations such as timer and filesystemwatcher ).
Of course, the application-related events are registered in this step.
----
Note that in some cases, INIT () is executed multiple times, for example, more than once when the framework is used...
Http://www.cnblogs.com/redfire0922/archive/2007/03/15/675549.html
A friend has encountered a similar problem.
Ii. Memory recycling, dispose, close, finalie (destructor in C)
. Net resources are managed and unmanaged. The so-called hosting refers to resources managed in CLR (general language runtime), which can be automatically recycled by CLR.
This is also known as GC (garbage collection mechanism ).
For unmanaged resources, such as database connections and COM connections, you need to manually clear and Recycle resources.
To clear unmanaged resources, we can use destructor to execute them. Although the execution time is unknown, they will eventually be executed.
Of course, there are also dispose () and close () methods. The difference between the two is that after close (), they must be opened with open (), while dispose () is completely destroyed.
---
When using the destructor, GC. Collect () is required before execution (GC, collect () is automatically executed in the automatic recycle mechanism, or you can call it explicitly)
Dispose () needs to be called explicitly, or use using ()
However, you must note that when using the destructor, at least two steps are taken: Call the function and reclaim the memory.
Then, after using () or *. Dispose () is used, GC will execute the Destructor again.
Therefore, add GC. supressfinalize (this) in dispose () to prevent re-calling the destructor.
Summary:
Dispose () and close () need to display the call. Dispose () can be called through using (). The Destructor cannot be explicitly called.
Dispose () and destructor are destroy objects, while close () is close. You can open them again through open.
The time for calling the Destructor is unknown, while dispose () is executed in explicit or using () mode, and close () is executed in explicit mode.
All three are used to destroy unmanaged objects.
A classic C #-dispose: 1 Private Bool _ Isdisposed = False ;
2 ~ Mytest ()
3 {
4//This. Close ();
5Dispose (False);
6}
7 /**//// <Summary>
8///Memory is released and needs to be explicitly called by such instances, such as SQL. Dispose (); or using ()
9/// </Summary>
10 Public Void Dispose ()
11 {
12 // Idisposable dispose = this as idisposable;
13 // If (dispose! = NULL)
14 // {
15 // Dispose. Dispose ();
16 // }
17 Dispose ( True );
18 GC. suppressfinalize ( This );
19 }
20 Protected Virtual Void Dispose ( Bool Disposing)
21 {
22 If ( ! _ Isdisposed)
23 {
24 If (Disposing)
25 {
26//Release of managed resources
27}
28 // Release of unmanaged Resources
29 _ Isdisposed = True ;
30 }
31 }