.NET interview questions: - How do you do object pooling in .NET?
Here is the .NET
interview questions on how to do object pooling in .NET.
COM+ reduces overhead by not creating object from scratch. So in COM+ when object is activated it’s activated, from pool and when it has deactivated it’s pushed back to the pool. Object pooling is configures by using the “ObjectPoolingAttribute” to the class.
Note:- When a class is marked with objectpooling attribute it can
not be inherited.
ObjectPooling(MinPoolSize :=
2, MaxPoolSize := 5, CreationTimeout := 20000)> _
Public Class testingclass
Inherits ServicedComponent
Public Sub DoWork()
' Method contents go here.
End Sub
End Class
Above is a sample code, which has the “Object Pooling” attribute defined. Below is a sample code, which uses the class.
Public Class App
Overloads Public Shared Sub
Main(args() As String)
Dim xyz As New
TestObjectPooling()
xyz.doWork()
ServicedComponent.DisposeObject
(xyz)
End Sub
End Class
Above is a sample code, which uses the object pooled object. Note the Dispose Object () This ensures its safe return to the object pool.
http://
http://www.questpond.com/
Contributed by:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small
E-learning company in India. We are very much active in making training videos ,
writing books and corporate trainings. Do visit my site http://www.questpond.com for
.NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=719
Click here to go on website
|