I am running a thread in C#. I have web form. I declared public string attribute in my web form. (e.g. string myVal) Then I called thread and assign value into myVal. It assign values in it. But when I exit from thread code, myVal become null.
Is there anyway to keep myVal value.
public string myVal;
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread myThread = new System.Threading.Thread(this.getVal);
myThread.SetApartmentState(System.Threading.ApartmentState.STA);
myThread.Start();
myThread.Join();
//I am not able to get myVal string over here.
}
private void getVal()
{
myVal = "I can easily get myVal over here.";
}