Skip to content

Commit e003331

Browse files
authored
Use discard _ for fire and forget task (#10231)
1 parent 8e7f9f5 commit e003331

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

src/NuGetGallery/App_Start/DefaultDependenciesModule.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,7 @@ private static void RegisterSwitchingDeleteAccountService(ContainerBuilder build
812812
.Register(c => new TopicClientWrapper(asyncAccountDeleteConnectionString, asyncAccountDeleteTopicName, configuration.ServiceBus.ManagedIdentityClientId))
813813
.SingleInstance()
814814
.Keyed<ITopicClient>(BindingKeys.AccountDeleterTopic)
815-
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
816-
.OnRelease(x => x.CloseAsync());
817-
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
815+
.OnRelease(x => _ = x.CloseAsync());
818816

819817
builder
820818
.RegisterType<AsynchronousDeleteAccountService>()
@@ -950,9 +948,7 @@ private static void RegisterAsynchronousEmailMessagingService(ContainerBuilder b
950948
.As<ITopicClient>()
951949
.SingleInstance()
952950
.Keyed<ITopicClient>(BindingKeys.EmailPublisherTopic)
953-
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
954-
.OnRelease(x => x.CloseAsync());
955-
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
951+
.OnRelease(x => _ = x.CloseAsync());
956952

957953
builder
958954
.RegisterType<EmailMessageEnqueuer>()
@@ -1107,18 +1103,14 @@ private void RegisterAsynchronousValidation(
11071103
.As<ITopicClient>()
11081104
.SingleInstance()
11091105
.Keyed<ITopicClient>(BindingKeys.PackageValidationTopic)
1110-
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
1111-
.OnRelease(x => x.CloseAsync());
1112-
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
1106+
.OnRelease(x => _ = x.CloseAsync());
11131107

11141108
builder
11151109
.Register(c => new TopicClientWrapper(symbolsValidationConnectionString, symbolsValidationTopicName, configuration.ServiceBus.ManagedIdentityClientId))
11161110
.As<ITopicClient>()
11171111
.SingleInstance()
11181112
.Keyed<ITopicClient>(BindingKeys.SymbolsPackageValidationTopic)
1119-
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
1120-
.OnRelease(x => x.CloseAsync());
1121-
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
1113+
.OnRelease(x => _ = x.CloseAsync());
11221114
}
11231115
else
11241116
{

0 commit comments

Comments
 (0)