asp:timer with threading
i have a timer on my aspx page as
<asp:Timer ID="timUpdate" runat="server" Enabled="false" Interval="5000" OnTick="timUpdate_Tick"/>
and i run different threads on the page to count the number of words in a document. each thread for an indivual page.
On pa开发者_Python百科ge load i start my timer. It works fine for first tick and fires the event
protected void timUpdate_Tick(object sender, EventArgs e)
{
if(db.value()==true)
Response.Redirect("abc.aspx");
}
i have checked that during debugging it works fine but after that my timer is enabled, interval is same but it doesn't fire the event.what can be the possible issue
You're setting Enable=false in the aspx, so I presume you're enabling it in code. It's possible if you've disabled viewstate that after the postback, the property hasn't persisted.
You could verify this by re-enabling the Enabled
property in your method:
protected void timUpdate_Tick(object sender, EventArgs e)
{
timUpdate.Enabled= true;
if (db.value()==true)
Response.Redirect("abc.aspx");
}
This isn't a nice solution, but it might work. You should probably either allow the controls state to be persisted, or enable the timer on each page request yourself (if the required condition is met).
精彩评论