/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Middleware/InMemoryOutbox/InMemoryOutboxDeferredMethod.cs
43 строки
907 B
Chris Patterson
Fixed in-memory outbox telemetry to capture ExecutionContext, which should properly flow activity traces
12 сен 2025, 21:17
12 сен 2025, 21:17
df4bd59
Код
Авторство
О чём код?
namespace MassTransit.Middleware.InMemoryOutbox; using System; using System.Threading; using System.Threading.Tasks; public class InMemoryOutboxDeferredMethod : IDisposable { readonly Func<Task> _method; ExecutionContext _executionContext; public InMemoryOutboxDeferredMethod(ExecutionContext executionContext, Func<Task> method) { _executionContext = executionContext; _method = method; } public void Dispose() { _executionContext?.Dispose(); } public async Task Run() { try { using var ec = _executionContext.CreateCopy(); Task task = null; ExecutionContext.Run(ec, _ => task = _method(), null); await task.ConfigureAwait(false); } finally { _executionContext?.Dispose(); _executionContext = null; } } }