Spots

*"How I Fixed a 300ms API Latency Spike—Without Touching the Database"*

csharp // Before: Potential leak await foreach (var item in asyncEnumerable) { // Process item } // After: Ensure cleanup await foreach (var item in asyncEnumerable.ConfigureAwait(false)) { // Process item } csharp // Before: Ignored cancellation await Task.Run(() => PerformCleanup());

// After: Respect cancellation await Task.Run(async () =>

// After: Respect cancellation await Task.Run(async () => { while (!cancellationToken.IsCancellationRequested) { await PerformCleanup(); await Task.Delay(100, cancellationToken); } }, cancellationToken); For further actions, you may consider blocking this person and/or reporting abuse

News

*"How I Fixed a 300ms API Latency Spike—Without Touching the Database"*

csharp // Before: Potential leak await foreach (var item in asyncEnumerable) { // Process item } // After: Ensure cleanup await foreach (var item in asyncEnumerable.ConfigureAwait(false)) { //…

@spots #dev
Source: Dev.to
See more like this