quest_capital
asked on
C# Set timer for viewbag message
I want a message to show/ change after 5 secs are up (I can do this in java script but I need to do it in C#)
I have a function that starts the timer and it works fine. However how can I change the viewbag message after the 5 sec.
Please show exp. code.
The Timer function work and it calls the OnTimeEvent ever 5 sec
Thx
I have a function that starts the timer and it works fine. However how can I change the viewbag message after the 5 sec.
Please show exp. code.
public ActionResult Balance()
{
var t = "false";
SetTimer();
while (exitFlag == true)
{
t = "true";
}
ViewBag.Response = t;
return View();
}
The Timer function work and it calls the OnTimeEvent ever 5 sec
private void SetTimer()
{
// Create a timer with a two second interval.
System.Timers.Timer aTimer = new System.Timers.Timer(3000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
//This does not work.....
//ViewBag.Response = "true";
exitFlag = true;
}
Thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.