当前位置:编程学习 > C#/ASP.NET >>

如何让webservice服务端只有一个实例和每会话一个实例

如题! --------------------编程问答-------------------- --------------------编程问答-------------------- 没人知道???????????????????!!!!!! --------------------编程问答-------------------- 使用单例模式,就是一个类永远只生成一个对象,在WEBSERVICE中的确是很好的方式。
这个你可以去MSDN搜索下singleton模式(貌似这样拼写的) --------------------编程问答-------------------- wcf --------------------编程问答-------------------- wcf 对这个问题是很简单的,在服务头上的特性就能解决

问题是webservice不知道如何解决 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- public sealed class Singleton {   
    static Singleton instance;   
    static object padlock = new object();   
  
    public Singleton() {   
    }   
  
    public static Singleton Instance {   
        get {   
            lock (padlock) {   
                if (instance == null) {   
                    instance = new Singleton();   
                }   
            }   
            return instance;   
        }   
    }   
}  
public sealed class Singleton {
    static Singleton instance;
    static object padlock = new object();

    public Singleton() {
    }

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


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jianuMan/archive/2010/06/13/5670042.aspx --------------------编程问答--------------------
引用 8 楼 jianuman 的回复:
public sealed class Singleton {  
  static Singleton instance;  
  static object padlock = new object();  
  
  public Singleton() {  
  }  
  
  public static Singleton Instance {  
  get {  ……


没有像WCF那样,给一个特性的属性赋值? --------------------编程问答-------------------- 没用过 wcf --------------------编程问答-------------------- 再顶起来。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,