看看行不行。http://samples.gotdotnet.com/quickstart/aspplus/doc/applications.aspx 

解决方案 »

  1.   

    public class NSQS : WebService 
    { Hashtable stockItems; 
    Hashtable logins; public NSQS() { string stockData = null; // populate stock items 
    this.stockItems = new Hashtable(); for(int i = 0; i < 50; i++) { 
    stockData = "" + i; 
    this.stockItems.Add(stockData , new StockItem(stockData, stockData, stockData, stockData, stockData, stockData)); 
    } this.logins = new Hashtable(); logins.Add("admin", "admin"); 
    logins.Add("testuser", "testuser"); 
    logins.Add("test", "test"); if(Application["stockItems"] == null) 

    Application.Lock(); 
    Application["stockItems"] = this.stockItems; 
    Application.UnLock(); 
    } if(Application["logins"] == null) 

    Application.Lock(); 
    Application["logins"] = this.logins; 
    Application.UnLock(); 

    } [WebMethod] 
    public bool validateLogin(string login, string passwd) { 
    bool res = false; 
    string loginPasswd = (string) logins[login]; if ((loginPasswd != null) || (passwd != null)) // || (!loginPasswd.Equal(passwd))) { 
    res = loginPasswd.Equals(passwd); return res; 
    } [WebMethod] 
    public void addStockItem(string code, string name, string desc, string highVal, string lowVal, string currentPrice) { StockItem stockItem = new StockItem(code, name, desc, highVal, lowVal, currentPrice); this.stockItems = (Hashtable) Application["stockItems"]; 
    stockItems.Add(code, stockItem); Application.Lock(); 
    //Application.Add("stockItems", this.stockItems); 
    Application["stockItems"] = this.stockItems; 
    Application.UnLock(); //stockItems.Add("1000", stockItem); //return queryStockItemByCode(code); 
    } } 
    用application.lock 试试
      

  2.   

    我要的不是application对象的啊,朋友们
      

  3.   

    public a as filestream=new filestream(.....)
            'Lock 
            Monitor.Enter(a)
            'write
           a.......
            'Unlock the queue.
            Monitor.Exit(a)