Geeks With Blogs
Dennis Ecclestone's BLOG December 2005 Entries
Singleton Design Pattern for .NET
When implementing the Singleton design pattern, we want to ensure that our code is thread-safe. Alot of samples use the Mutex to ensure that the creation of the object is thread-safe. A typical example is as follows; Bad Example: Do not use this code Public Class Singleton Private Shared _singleton As Singleton Private Shared _mu As New Mutex Private Sub New() End Sub Public Shared Function GetInstance() As Singleton _mu.WaitOne() Try If _singleton Is Nothing Then _singleton = New Singleton End If ......

Posted On Thursday, December 22, 2005 2:29 PM

Copyright © Dennis Ecclestone | Powered by: GeeksWithBlogs.net