Skip to content

Make async function real #1065

@zhuxb711

Description

@zhuxb711

Currently, all the async function seems will call the "Sync" one and simply return a Task.CompleteTask.

However, this is not the real async function and will block the caller thread until the operation complete. Therefore, it's no difference than the sync one. Make sure that you implement the async function separately. For example: use underlying stream async function: Stream.WriteAsync() Stream.ReadAsync() Stream.FlushAsync()

public virtual async Task WriteAsync(
string filename,
Stream source,
DateTime? modificationTime,
CancellationToken cancellationToken = default
)
{
// Default implementation calls synchronous version
// Derived classes should override for true async behavior
Write(filename, source, modificationTime);
await Task.CompletedTask.ConfigureAwait(false);
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions