Reputation: 1470
in front of a Room i have a Panel. That Panel is displaying the occupancy time, for example 14:00 - 15:30. If someone want to use that Room for that time he has to push a CHECK_IN Button on the Panel. So the system knows there is someone in the Room. Now i want that if nobody use that Button after 20 min from 14:00, the occupancy time should be canceled.
i have already written the Query for the cancel. But i need something similar to a Timer, which execute the Query after 20 min. How can i do that?
Thanks in advance
Upvotes: 0
Views: 1661
Reputation: 82136
Use a Timer and put your cancel code in the callback.
public void StartCheckin(int dueTime)
{
var t = new Timer(new TimerCallback(CancelCheckin));
t.Change(dueTime, Timeout.Infinite);
}
private void CancelCheckin(object state)
{
// cancel checkin
// dispose of timer
((Timer)state).Dispose();
}
Upvotes: 4
Reputation: 13212
You could use the Timer
object in C#
http://msdn.microsoft.com/en-us/library/system.timers.timer%28v=vs.71%29.aspx
Upvotes: 0