Storage: fix the cmdlets hang in event issue #3299
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The PR fixed 1 issues:
Call some storage cmdlets from event will hang. To fix the issue add ConfigureAwait(false) for all aycn call. (https://msdn.microsoft.com/en-us/library/system.threading.tasks.task.configureawait%28v=vs.110%29.aspx)
We have verified the cmdlets won't hang in WPF or WinForm event now. and it also work well when call from Console.
Issue Link : #3205
This is a safe change since:
This is a Best Practices in Asynchronous Programming https://msdn.microsoft.com/en-us/magazine/jj991977.aspx , the exception is “Methods that require context”
For the storage cmdlets that use Async call, I have checked they are all Azure Server request or DMlib transfer job, which don’t require context. So it’s safe to add ConfigureAwait(false) to avoid the hang.
And as PowerShell is not GUI program, it’s even safe to add ConfigureAwait(false).
Test:
Storage team regression and On Demand test both pass with the code change:
http://azuresdkci.cloudapp.net/view/1-AzurePowerShell/job/powershell-demand/1360/
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines - no cmdlet change
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThrough
parameter.Cmdlet Parameter Guidelines - no cmdlets parameter change