Skip to content

Suggestion: Async/Await implementation. #82

@mveril

Description

@mveril

Hello
Can you add an async version of DISM api.
For example with EnableFeatureByPackageNameAsync:

public static Task<bool> EnableFeatureByPackageNameAsync(DismSession session, string featureName, string packageName, bool limitAccess, bool enableAll, List<string> sourcePaths,  CancellationToken token, IProgress<DismProgressAsync> progress);

With DismProgressAsync is the same as DismProgress without cancellation
If the task result is bool==true reboot are required.
with that the library customer can do:

class MyprogressReporter : iProgress<DismProgressAsync>
{
public void Report (DismProgressAsync value)
{
  // update the UI
}
...
}
...
var progress=new MyprogressReporter();
CancellationTokenSource source = new CancellationTokenSource();

var tsk = EnableFeatureByPackageNameAsync(session, "myfeature", string.Empty, false, true, new List<string>(), source.Token, progress);
//if the user want to cancel
source.Cancel()
//Or after a delay
source.CancelAfter(delay);
// Or wait for the result
bool rebootRequired = await tsk;

It's easily implementable with TaskCompletionSource.
I hope I did not make any mistakes.
Thank you for your library.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions