I use DispacherTimer to auto-save a file. The code is like the following:
void beginAutoSave()
{
_autoSaveDispacherTimer = new DispatcherTimer();
_autoSaveDispacherTimer.Interval = TimeSpan.FromMinutes(1);
_autoSaveDispacherTimer.Tick += new EventHandler(onAutoSaveTick);
_autoSaveDispacherTimer.Start();
}
void onAutoSaveTick(object sender, EventArgs e)
{
// I save the file with a randomly generated file name
}
I call beginAutoSave() just once. The problem is that in each Tick event, two different files are being saved. In other words, onAutoSaveTick(...) method is called twice. The call stack seems to be the same in both calls. Where is my mistake?
Any help is appreciated. Thanks.