-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update the task-based async APIs added to PowerShell to return a Task object directly #9079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3083,10 +3083,8 @@ public IAsyncResult BeginInvoke<TInput, TOutput>(PSDataCollection<TInput> input, | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task<PSDataCollection<PSObject>> InvokeAsync() | ||
| { | ||
| return await Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke(), _endInvokeMethod).ConfigureAwait(false); | ||
| } | ||
| public Task<PSDataCollection<PSObject>> InvokeAsync() | ||
| => Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke(), _endInvokeMethod); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing I'm curious about is that the documentation here says that the I tried looking into this, and the doc written for wrapping the old API with the new one here, but I'm not quite sure what needs to be done to turn the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's an SO post that touches on this question
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's another one that has some more detail
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, after reading a bit more, it looks like the callback functionality would need to be supported by PowerShell itself and passed into a I was proceeding under the impression that it might be possible to fudge that with a wrapping lambda based on the documentation's recommendation of "use this overload", but I'm guessing that's wrong.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, our Begin/End implementation doesn't strictly conform to the APM contract.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will improve?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a reason to update the existing APM APIs.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was not addressed comment #8056 (comment)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can defer opening that issue until we get some real feedback on those async APIs that request performance enhancement. |
||
|
|
||
| /// <summary> | ||
| /// Invoke a PowerShell command asynchronously. | ||
|
|
@@ -3126,8 +3124,8 @@ public async Task<PSDataCollection<PSObject>> InvokeAsync() | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> input) | ||
| => await Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<T>(input), _endInvokeMethod).ConfigureAwait(false); | ||
| public Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> input) | ||
| => Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<T>(input), _endInvokeMethod); | ||
|
|
||
| /// <summary> | ||
| /// Invoke a PowerShell command asynchronously. | ||
|
|
@@ -3177,8 +3175,8 @@ public async Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> input, PSInvocationSettings settings, AsyncCallback callback, object state) | ||
| => await Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<T>(input, settings, callback, state), _endInvokeMethod).ConfigureAwait(false); | ||
| public Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> input, PSInvocationSettings settings, AsyncCallback callback, object state) | ||
| => Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<T>(input, settings, callback, state), _endInvokeMethod); | ||
|
|
||
| /// <summary> | ||
| /// Invoke a PowerShell command asynchronously. | ||
|
|
@@ -3225,8 +3223,8 @@ public async Task<PSDataCollection<PSObject>> InvokeAsync<T>(PSDataCollection<T> | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task<PSDataCollection<PSObject>> InvokeAsync<TInput, TOutput>(PSDataCollection<TInput> input, PSDataCollection<TOutput> output) | ||
| => await Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<TInput, TOutput>(input, output), _endInvokeMethod).ConfigureAwait(false); | ||
| public Task<PSDataCollection<PSObject>> InvokeAsync<TInput, TOutput>(PSDataCollection<TInput> input, PSDataCollection<TOutput> output) | ||
| => Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<TInput, TOutput>(input, output), _endInvokeMethod); | ||
|
|
||
| /// <summary> | ||
| /// Invoke a PowerShell command asynchronously and collect | ||
|
|
@@ -3284,8 +3282,8 @@ public async Task<PSDataCollection<PSObject>> InvokeAsync<TInput, TOutput>(PSDat | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task<PSDataCollection<PSObject>> InvokeAsync<TInput, TOutput>(PSDataCollection<TInput> input, PSDataCollection<TOutput> output, PSInvocationSettings settings, AsyncCallback callback, object state) | ||
| => await Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<TInput, TOutput>(input, output, settings, callback, state), _endInvokeMethod).ConfigureAwait(false); | ||
| public Task<PSDataCollection<PSObject>> InvokeAsync<TInput, TOutput>(PSDataCollection<TInput> input, PSDataCollection<TOutput> output, PSInvocationSettings settings, AsyncCallback callback, object state) | ||
| => Task<PSDataCollection<PSObject>>.Factory.FromAsync(BeginInvoke<TInput, TOutput>(input, output, settings, callback, state), _endInvokeMethod); | ||
|
|
||
| /// <summary> | ||
| /// Begins a batch execution. | ||
|
|
@@ -3808,10 +3806,8 @@ public void EndStop(IAsyncResult asyncResult) | |
| /// <exception cref="ObjectDisposedException"> | ||
| /// Object is disposed. | ||
| /// </exception> | ||
| public async Task StopAsync(AsyncCallback callback, object state) | ||
| { | ||
| await Task.Factory.FromAsync(BeginStop(callback, state), _endStopMethod).ConfigureAwait(false); | ||
| } | ||
| public Task StopAsync(AsyncCallback callback, object state) | ||
| => Task.Factory.FromAsync(BeginStop(callback, state), _endStopMethod); | ||
|
|
||
| #endregion | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.