Author: mammadkoma | Posted on: 10/12/2010 9:37:29 AM | Views : 374

Hi all. In my web page I have two buttons.
first start a thread that it increase one value to a variable every two seconds.
When I click second button, my thread will stop. why? what should I do?

public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Application["s"] = 0; Thread thr = new Thread(new ThreadStart(func)); thr.Start(); } public void func() { System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(timerTick), null, 0, 2000); } private void timerTick(object a) { int b=Int32.Parse(Application["s"].ToString()); b++; Application["s"] = b; SqlConnectio ...

Go to the complete details ...