carsey88
carsey88

Reputation: 377

Auto save - WPF C#

Is there a way in which I can save details from a ListView that doesnt require me to use the save dialog box everytime and allows me to call it within a certain time span. So 'save' rather than 'save as' everytime.

Upvotes: 6

Views: 1999

Answers (1)

Greg Andora
Greg Andora

Reputation: 1372

You can use a DispatchTimer with a callback to a method to perform your save.

    DispatcherTimer autosaveTimer = new DispatcherTimer(TimeSpan.FromSeconds(autosaveInterval), DispatcherPriority.Background, new EventHandler(DoAutoSave), Application.Current.Dispatcher);

    private void DoAutoSave(object sender, EventArgs e)
    {
        // Enter save logic here...
    }

Upvotes: 7

Related Questions