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 ...