18 lines
530 B
Plaintext
18 lines
530 B
Plaintext
![]() |
Returning <code>Nothing</code> from a non-<code>async</code> <code>Task</code>/<code>Task(Of T)</code> method will cause a <code>NullReferenceException</code> at runtime. This problem can be avoided by returning <code>Task.FromResult(Of T)(Nothing)</code> instead.
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
Public Function GetFooAsync() As Task(Of Object)
|
||
|
Return Nothing
|
||
|
End Function
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
Public Function GetFooAsync() As Task(Of Object)
|
||
|
Return Task.FromResult(Of Object)(Nothing)
|
||
|
End Function
|
||
|
----
|