I have used the singleton pattern to create a single instance of a web service that I use in my win forms application. I have seen that this is good practice for web applications. I was wondering if this is the same for winform apps too? Also, should I worry about disposing of the web service (i.e. the proxy object afterwards) - it has a .Dispose method but I am not calling it anywhere in my code. In my application I am calling all my web methods asynchronously. This might sounds silly but I don't know where I need to call dispose. Can anyone help?
class ListService
{
private static RetrieveList s_proxy;
private static readonly object s_lock = new object();
private static readonly string s_webServiceURL = Authentication.RetrieveListUrl;
internal static RetrieveList Proxy
{
get
{
lock (s_lock)
{
if (s_proxy == null)
{
s_proxy = new RetrieveList();
s_proxy.Url = s_webServiceURL;
}
return s_proxy;
}
}
}
}