> For the complete documentation index, see [llms.txt](https://tariksavas.gitbook.io/tarsave/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tariksavas.gitbook.io/tarsave/docs/how-to-use/datapersistenceservice/saveasync.md).

# SaveAsync

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

**Purpose:** Saves data of type T asynchronously to a specified file path.&#x20;

**Parameters:**&#x20;

* key: A string that specifies the file path.&#x20;
* data: The data to save, constrained to reference types (classes).&#x20;
* cancellationToken: A token to signal cancellation of the save operation.&#x20;

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

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