tarsave
  • Documentation
    • Introduction
    • Installation
    • How to Use
      • DataPersistenceConfig
      • Encryption
      • Compression
      • DataPersistenceBuilder
        • SetDataPersistenceConfig
        • Build
      • DataPersistenceService
        • Save
        • SaveAsync
        • AutoSaveAsync
        • Load
        • LoadAsync
        • Delete
        • DeleteAll
      • Transform Data
      • Audio Data
  • Log
    • Change Log
      • v1.0.6
      • v1.0.5
      • v1.0.4
      • v1.0.3
      • v1.0.2
Powered by GitBook
On this page
  1. Documentation
  2. How to Use
  3. DataPersistenceService

AutoSaveAsync

Task AutoSaveAsync<T>(string key, T data, int intervalSeconds, 
    CancellationToken cancellationToken)

Purpose: Periodically saves data of type T asynchronously at regular intervals.

Parameters:

  • key: A string to define the file path.

  • data: The data to save periodically, constrained to reference types.

  • intervalSeconds: The time interval (in seconds) between each save operation.

  • cancellationToken: A token to cancel the auto-save loop.

Return Value: An async Task.

public void AutoSave()
{
    _dataPersistenceService.AutoSaveAsync("Key", _data, 3, _cancellationToken);
}
PreviousSaveAsyncNextLoad

Last updated 6 months ago