Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 554 Bytes

PH_S030.md

File metadata and controls

9 lines (5 loc) · 554 Bytes

PH_S030 - Async Void Method Invocation

Problem

The primary use of async methods that returnvoid is for event handlers. Asynchronous methods that return void have different error handling that is most-likely undesired at the current location.

Solution

Replace the invoked method with an implementation that is awaitable, i.e., one that returns a Task object. If this leads to code duplication, extract the body of the async void method into an awaitable implementation and invoke the created method from within the async void one.