Skip to content

Commit 92369f3

Browse files
committed
Merge pull request #424 from sharwell/fix-421
Fix 421
2 parents e84a5c9 + f8507d6 commit 92369f3

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

src/Documentation/Content/AsynchronousServices.aml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
<para>
99
The openstack.net SDK is migrating to an asynchronous service model using the <token>TaskBasedAsync</token>
1010
for ongoing feature support. This page contains information about several aspects of the asynchronous interfaces
11-
which could result in some confusion during development. It also describes the inclusion of extension methods
12-
that allow new product features to be used in code that is not allowed to make asynchronous API
13-
calls.
11+
which could result in some confusion during development.
1412
</para>
13+
<para>
14+
Users unfamiliar with asynchronous programming may find the following introduction particularly valuable.
15+
</para>
16+
<list class="bullet">
17+
<listItem>
18+
<para>
19+
<externalLink>
20+
<linkText>Async and Await</linkText>
21+
<linkUri>http://blog.stephencleary.com/2012/02/async-and-await.html</linkUri>
22+
</externalLink>
23+
</para>
24+
</listItem>
25+
</list>
1526
</introduction>
1627

1728
<section address="LanguageSupport">
@@ -194,6 +205,14 @@
194205
execution of the task itself. The documentation for asynchronous methods does not distinguish between these
195206
two cases, allowing for any of the specified exceptions to be thrown in either manner.
196207
</para>
208+
<alert class="important">
209+
<para>
210+
This documentation uses the term asynchronous method to refer to any method with a return type of
211+
<codeEntityReference>T:System.Threading.Tasks.Task</codeEntityReference> or
212+
<codeEntityReference>T:System.Threading.Tasks.Task`1</codeEntityReference>. Languages with built-in support
213+
for asynchronous programming have their own related terminology which may differ in meaning.
214+
</para>
215+
</alert>
197216
</content>
198217

199218
<sections>
@@ -231,14 +250,17 @@
231250
<para>
232251
This library additionally ensures that exceptions thrown by asynchronous operations are not wrapped in
233252
multiple layers of <codeEntityReference>T:System.AggregateException</codeEntityReference>. In other words,
234-
an <codeEntityReference>T:System.AggregateException</codeEntityReference> thrown during the asynchronous
253+
an <codeEntityReference>T:System.ArgumentException</codeEntityReference> thrown during the asynchronous
235254
execution of a task will result in the
236255
<codeEntityReference>P:System.Threading.Tasks.Task.Exception</codeEntityReference> property returning an
237-
<codeEntityReference>T:System.AggregateException</codeEntityReference> with exactly one inner exception,
238-
which is the original <codeEntityReference>T:System.ArgumentException</codeEntityReference>. This
239-
guarantee simplifies the use of the API is languages that support <token>AsyncAwait</token>, since those
240-
operators automatically unwrap the first layer of
241-
<codeEntityReference>T:System.AggregateException</codeEntityReference>.
256+
<codeEntityReference>T:System.AggregateException</codeEntityReference>, and that exception will not
257+
contain an nested instances of <codeEntityReference>T:System.AggregateException</codeEntityReference> in
258+
the <codeEntityReference>P:System.AggregateException.InnerExceptions</codeEntityReference> collection. In
259+
most cases, the <codeEntityReference>T:System.AggregateException</codeEntityReference> wraps exactly one
260+
inner exception, which is the original
261+
<codeEntityReference>T:System.ArgumentException</codeEntityReference>. This guarantee simplifies the use
262+
of the API is languages that support <token>AsyncAwait</token>, since those operators automatically unwrap
263+
the first layer of <codeEntityReference>T:System.AggregateException</codeEntityReference>.
242264
</para>
243265
<code language="cs" region="ExceptionDuringTaskExecution" source="..\Samples\CSharpCodeSamples\AsynchronousExceptionsExamples.cs"/>
244266
<code language="vb" region="ExceptionDuringTaskExecution" source="..\Samples\VBCodeSamples\AsynchronousExceptionsExamples.vb"/>

src/Samples/CSharpCodeSamples/AsynchronousExceptionsExamples.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public void ExceptionPriorToTaskCreation()
1515
}
1616
catch (ArgumentException ex)
1717
{
18-
// ex was thrown directly by SomeOperationAsync. If SomeOperationAsync is marked with the `async`
19-
// keyword, then ex was thrown prior to the first use of the `await` keyword within the implementation.
18+
// ex was thrown directly by SomeOperationAsync. This cannot occur if SomeOperationAsync is an async
19+
// function (§10.15 - C# Language Specification Version 5.0).
2020
}
2121
#endregion
2222
}
@@ -35,9 +35,8 @@ public void ExceptionDuringTaskExecution()
3535
if (ex == null)
3636
throw;
3737

38-
// ex was thrown during the asynchronous portion of SomeOperationAsync. If SomeOperationAsync is marked
39-
// with the `async` keyword, then ex was thrown after the first use of the `await` keyword within the
40-
// method.
38+
// ex was thrown during the asynchronous portion of SomeOperationAsync. This is always the case if
39+
// SomeOperationAsync is an async function (§10.15 - C# Language Specification Version 5.0).
4140
}
4241
#endregion
4342
}

src/Samples/VBCodeSamples/AsynchronousExceptionsExamples.vb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Public Class AsynchronousExceptionsExamples
88
Try
99
Dim myTask As Task = SomeOperationAsync()
1010
Catch ex As ArgumentException
11-
' ex was thrown directly by SomeOperationAsync. If SomeOperationAsync Is marked with the `Async`
12-
' keyword, then ex was thrown prior to the first use of the `Await` keyword within the implementation.
11+
' ex was thrown directly by SomeOperationAsync. This cannot occur if SomeOperationAsync is an async method
12+
' (§10.1.3 - Visual Basic Language Specification Version 11.0).
1313
End Try
1414
' #End Region
1515
End Sub
@@ -25,9 +25,8 @@ Public Class AsynchronousExceptionsExamples
2525
Throw
2626
End If
2727

28-
' ex was thrown during the asynchronous portion of SomeOperationAsync. If SomeOperationAsync Is marked
29-
' with the `Async` keyword, then ex was thrown after the first use of the `Await` keyword within the
30-
' method.
28+
' ex was thrown during the asynchronous portion of SomeOperationAsync. This is always the case if
29+
' SomeOperationAsync is an async method (§10.1.3 - Visual Basic Language Specification Version 11.0).
3130
End Try
3231
' #End Region
3332
End Sub

0 commit comments

Comments
 (0)