1
我有下面的代碼在我的ASP.NET 4.0 Web應用程序的Global.asax中詞典<字符串,字符串>在Global.asax中定義的Application.Add
protected void Application_Start(object sender, EventArgs e)
{
Dictionary<string, string> AllCompanyList = new Dictionary<string, string>();
Application.Add("GlobalCompanyList", AllCompanyList);
Thread ProcessCompanyThread = new Thread(new ParameterizedThreadStart(CompanyThread.Start));
ProcessCompanyThread.IsBackground = true;
ProcessCompanyThread.Start(AllCompanyList);
}
我通過
訪問另一頁上Dictionary<string, string> AllCompanyList = (Dictionary<string, string>)HttpContext.Current.Application["GlobalCompanyList"];
首先,是 「GlobalCompanyList」 只有在IIS中的 一生一個實例?
二,是「GlobalCompanyList」 線程安全地訪問或修改ProcessProanyThread中的 ?如果是 不是那麼我該怎麼做才能使它 線程安全?
感謝您的幫助。