aws-sdk-net: Async methods fail
After upgrading to the latest version, the EncryptAsync thread remais locked
using (var client = new AmazonKeyManagementServiceClient())
using (var plainText = new MemoryStream(Encoding.UTF8.GetBytes("Amazon Web Services")))
{
var request = new EncryptRequest
{
KeyId = "Aws-Kms-Login-Key",
Plaintext = plainText
};
var result = client.EncryptAsync(request).Result.CiphertextBlob.ToArray();
}
To overcome the issue, it is required to run the code within a different task
var result = Task.Run(() => _ = client.EncryptAsync(request).Result).Result.CiphertextBlob.ToArray();
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 18 (11 by maintainers)
They just need to finally merge https://github.com/aws/aws-sdk-net/pull/1659
It is built into fxcop. I would recommend that even if you disable all the other rules https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019