I need to change the state management from inProc to StateServer in old application.
There is method that execute within a new thread.
The code look like as follows.
protected void btnTransaction_Click(object sender, EventArgs e)
{
timerTrans.Enabled = true;
timerTrans.Interval = 200;
Thread thread = new Thread(new ParameterizedThreadStart(DoAllWork));
thread.Start(dbConnectionString);
}
public void DoAllWork(object connectionString)
{
DBAccess dba = new DBAccess(connectionString.ToString());
Session["NextTransactionId"] = dba.getNewTransactionId();
//Other work
foreach(transaction t in transactions)
{
ShowTrasnactionStatus("Processing transaction "+t.id);
}
//Other work
Session["FinalStatus"] = "All Transactions Completed";
Session["TransactionStatus"] = "Done";
}
private void ShowTrasnactionStatus(string statusMsg)
{
Session["TransactionStatus"] = statusMsg;
}
protected void timerTrans_Tick(object sender, EventArgs e)
{
lblStatus.Text = Session["TransactionStatus"].ToString();
if (Session["TransactionStatus"].ToString() == "Done")
{
//Final Stage of Transaction Processing
lblStatus.Text = "Getting final status ...";
billEndTime = DateTime.Now;
ShowFinalStatus();
timerBilling.Enabled = false;
}
}
When the web garden is enabled the usage of session variables to update the status does not work as expected.
- I have tried using class variable instead of session variables.
- Used Cache instead of session.
None of them worked for me.
Note: This code is from a existing application that was developed at least 8 years ago.
I only want to run this in web garden without breaking the functionality.