I believe that you can use GLib.Source.Remove to remove the event source that GLib.Timeout.Add will return to you when you need to re-initialize the timer. Pls see if the code below will work:
private uint _timerID = 0;
widget.Changed += delegate
{
if (_timerID>0)
{
GLib.Source.Remove(_timerID);
_timerID = 0;
}
_timerID = GLib.Timeout.Add (2000, () =>
{
Save();
_timerID = 0;
return false;
});
};
System.Timers.Timer. Smth :
System.Timers.Timer _timer = null;
widget.Changed += delegate
{
if (_timer==null)
{
_timer = new Timer(5000);
_timer.AutoReset = false;
_timer.Elapsed += delegate
{
Save();
};
_timer.Start();
}
else
{
_timer.Stop();
_timer.Start();
}
};
, ,