Gayan,

can any body giv me a hint where to start to implement a Singleton Web
Service in Mono.

Why are you starting another thread?

http://lists.ximian.com/pipermail/mono-list/2005-October/029190.html

Save the (untested) sample as SingletonService.asmx into your
ASP.NET app's folder.

<%@ WebService Language="c#" Class="WebServiceTests.SingletonService" %>

using System;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace WebServiceTests
{
        interface ISingleton
        {
                string Test ();
        }

        // stock singleton implementation
        class Singleton : ISingleton
        {
                static Singleton _instance;
                static object _instanceLock = new object ();

                public static Singleton Instance
                {
                        get {
                                lock (_instanceLock) {
                                        if (_instance == null)
                                                _instance = new Singleton ();
                                        return _instance;
                                }
                        }
                }

                public string Test ()
                {
                        return "whatever";
                }
        }


        public class SingletonService : System.Web.Services.WebService,
                ISingleton
        {
                [WebMethod]
                public string Test ()
                {
                        return Singleton.Instance.Test ();
                }
        }
}

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to