microsoft / microsoft/sqlmanagementobjects

Can TaskCompletionSource be used with Backup class?

Open
#161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
143
Forks
28
PR merge metrics
No merged PRs in 30d

Description

I would like a method to call Backup.SqlBackupAsync and return a TaskCompletionSource.Task in order to await the completion of the Backup process.

Currently, the Backup.Wait() method appears to be the only definitive way to know when a Backup.SqlBackupAsync(Server) call has completed entirely. Is there another way that does not require calling a blocking method?

The Complete event is unreliable because if there's an error the Complete event is never raised.

The Information event is unreliable because there's no way to know when the "final" Information event has been raised.

The PercentageComplete event is unreliable because, at least in some cases, an error causes the event to not be raised at all.

My current methodology is to call Backup.Wait() via Task.Run() and return that Task. This is functional, but not ideal, because it's creating a new thread whose entire job is to wait.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining Backup.SqlBackupAsync(Server), Backup.Wait(), and the Complete, Information, and PercentageComplete events described in the issue. Determine how completion and errors are surfaced, then verify that the proposed awaitable approach avoids a blocking wait and reliably reports the backup outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.