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

SaveAsync

Task<bool> SaveAsync<T>(string key, T data, 
    CancellationToken cancellationToken = default)

Purpose: Saves data of type T asynchronously to a specified file path.

Parameters:

  • key: A string that specifies the file path.

  • data: The data to save, constrained to reference types (classes).

  • cancellationToken: A token to signal cancellation of the save operation.

Return Value: Returns a Task that indicates whether the save operation was successful.

public async Task SaveAsync()
{
    bool result = 
        await _dataPersistenceService.SaveAsync("Key", _data, _cancellationToken);
}

PreviousSaveNextAutoSaveAsync

Last updated 6 months ago