From 16f964b11ccd33387ae75849a389e3a58977b924 Mon Sep 17 00:00:00 2001 From: Garrett Beatty Date: Wed, 26 Nov 2025 18:48:26 -0500 Subject: [PATCH] Update initiated, complete and failed events to not fire in background --- .../S3/Custom/Transfer/TransferUtilityDownloadRequest.cs | 6 +++--- .../S3/Custom/Transfer/TransferUtilityUploadRequest.cs | 6 +++--- .../Services/S3/IntegrationTests/TransferUtilityTests.cs | 6 +----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/sdk/src/Services/S3/Custom/Transfer/TransferUtilityDownloadRequest.cs b/sdk/src/Services/S3/Custom/Transfer/TransferUtilityDownloadRequest.cs index f7ba5f97b943..95db655a02f7 100644 --- a/sdk/src/Services/S3/Custom/Transfer/TransferUtilityDownloadRequest.cs +++ b/sdk/src/Services/S3/Custom/Transfer/TransferUtilityDownloadRequest.cs @@ -193,7 +193,7 @@ internal void OnRaiseProgressEvent(WriteObjectProgressArgs progressArgs) /// DownloadInitiatedEventArgs args internal void OnRaiseTransferInitiatedEvent(DownloadInitiatedEventArgs args) { - AWSSDKUtils.InvokeInBackground(DownloadInitiatedEvent, args, this); + DownloadInitiatedEvent?.Invoke(this, args); } /// @@ -202,7 +202,7 @@ internal void OnRaiseTransferInitiatedEvent(DownloadInitiatedEventArgs args) /// DownloadCompletedEventArgs args internal void OnRaiseTransferCompletedEvent(DownloadCompletedEventArgs args) { - AWSSDKUtils.InvokeInBackground(DownloadCompletedEvent, args, this); + DownloadCompletedEvent?.Invoke(this, args); } /// @@ -211,7 +211,7 @@ internal void OnRaiseTransferCompletedEvent(DownloadCompletedEventArgs args) /// DownloadFailedEventArgs args internal void OnRaiseTransferFailedEvent(DownloadFailedEventArgs args) { - AWSSDKUtils.InvokeInBackground(DownloadFailedEvent, args, this); + DownloadFailedEvent?.Invoke(this, args); } } diff --git a/sdk/src/Services/S3/Custom/Transfer/TransferUtilityUploadRequest.cs b/sdk/src/Services/S3/Custom/Transfer/TransferUtilityUploadRequest.cs index 7e54dc52d5d5..879b4395849d 100644 --- a/sdk/src/Services/S3/Custom/Transfer/TransferUtilityUploadRequest.cs +++ b/sdk/src/Services/S3/Custom/Transfer/TransferUtilityUploadRequest.cs @@ -276,7 +276,7 @@ internal bool IsSetPartSize() /// UploadInitiatedEventArgs args internal void OnRaiseTransferInitiatedEvent(UploadInitiatedEventArgs args) { - AWSSDKUtils.InvokeInBackground(UploadInitiatedEvent, args, this); + UploadInitiatedEvent?.Invoke(this, args); } /// @@ -285,7 +285,7 @@ internal void OnRaiseTransferInitiatedEvent(UploadInitiatedEventArgs args) /// UploadCompletedEventArgs args internal void OnRaiseTransferCompletedEvent(UploadCompletedEventArgs args) { - AWSSDKUtils.InvokeInBackground(UploadCompletedEvent, args, this); + UploadCompletedEvent?.Invoke(this, args); } /// @@ -294,7 +294,7 @@ internal void OnRaiseTransferCompletedEvent(UploadCompletedEventArgs args) /// UploadFailedEventArgs args internal void OnRaiseTransferFailedEvent(UploadFailedEventArgs args) { - AWSSDKUtils.InvokeInBackground(UploadFailedEvent, args, this); + UploadFailedEvent?.Invoke(this, args); } diff --git a/sdk/test/Services/S3/IntegrationTests/TransferUtilityTests.cs b/sdk/test/Services/S3/IntegrationTests/TransferUtilityTests.cs index 0cb09b347c74..8135a0903229 100644 --- a/sdk/test/Services/S3/IntegrationTests/TransferUtilityTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/TransferUtilityTests.cs @@ -2125,11 +2125,7 @@ public void AssertEventFired() if (EventException != null) throw EventException; - // Since AWSSDKUtils.InvokeInBackground fires the event in the background it is possible that we check too early that the event has fired. In this case, we sleep and check again. - for (int retries = 1; retries < 5 && !EventFired; retries++) - { - Thread.Sleep(1000 * retries); - } + // Since events are now fired synchronously, we can check immediately without retries Assert.IsTrue(EventFired, $"{typeof(T).Name} event was not fired"); } }