我試圖讓Int32.Parse(Request.QueryString["PLCID"].ToString())
在線程方法的價值,當一個錯誤,我試圖用parameterizedthread但zhcon失敗ASP.NET:如何獲取線程方法中QueryString的值?
這裏我的代碼片斷
protected void btnReqConfirm_Click(object sender, EventArgs e)
{
Int32 val = Int32.Parse(Request.QueryString["PLCID"].ToString());
id = Guid.NewGuid();
ThreadStart ts = new ThreadStart(longRunningProcess);
Thread th = new Thread(ts);
th.Start();
Response.Redirect("Status.aspx?ID="+id.ToString());
}
protected void longRunningProcess()
{
String _MachineName = String.Empty;
_MachineIP = String.Empty;
DBLayer.getMachineByPLCID(Int32.Parse(Request.QueryString["PLCID"].ToString()), out _MachineName, out _MachineIP);
if (DBLayer.insertRequest(User.Identity.Name, DBLayer.getMachineID(_MachineName), Convert.ToDateTime(lblReqFromVal.Text), Convert.ToDateTime(lblReqToVal.Text)))
{
_PLCName = DBLayer._getPlCByID(Int32.Parse(Request.QueryString["PLCID"].ToString()));
//stop mail now
LogicLayer.AddNewListItem("Confirmation Mail", "You can initiate your session directly from this link : " + string.Format(@"http://IP/RRRProject/DirectSessionPage.aspx?Machine={0}", _MachineIP), (User.Identity.Name).Substring(5) + "@invensys.com");
lblConfirmationMessage.Visible = true;
lblConfirmationMessage.ForeColor = Color.Green;
Thread.Sleep(9000);
SimpleProcessCollections.Add(id, "Some result.");
}
}
什麼想法?
介意發佈您提到的這個錯誤的一些細節?此外,使用asp.net進行多線程並不像傳統應用程序那樣工作。在主線程已經完成Request.Response()後,你不能有一個側線程更新控件。 (也許你想看看AJAX?) –
你試過我的解決方案嗎? –