crc-org / tray-windows

CodeReady Containers tray for windows
Apache License 2.0
2 stars 4 forks source link

Refactor: Suppress await warnings; eg. for telemetry calls #122

Closed gbraad closed 3 years ago

gbraad commented 3 years ago

Refactor: suppress await/async warning

A warning is shown on build about the call not being awaited. However, this is not something that is needed in case of the telemetry calls. Either we can choose to use pragma directives, such as:

#pragma warning disable 4014
SomeAsyncMethod();
#pragma warning restore 4014

or in the chosen case, just use

_ = SomeAsyncMethod();

to discard the return value.

Refactor: add extension method to show NoAwait intent

Not only does this suppress the warning, but it also more clearly indicate the intent that the call is not awaited.

SomeAsyncMethod().NoAwait();
gbraad commented 3 years ago

@anjannath WDYT?

anjannath commented 3 years ago

@gbraad Sorry about the delay, looks good to me 👍🏽