Scope troubles
# help-with-umbraco
n
Hi All. I'm trying to write a health check using the aspnetcore.healthchecks library https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks. This health check needs to call some umbraco services that call the database. I'm getting scope errors, however I can't seem to use the suggest fix of calling SuppressFlow. Any thoughts? Error: The Scope 177711a4-1cbe-486e-b353-50b10baf24a7 being disposed is not the Ambient Scope f879b0c2-d877-4bc7-bc2e-da43944e31c4. This typically indicates that a child Scope was not disposed, or flowed to a child thread that was not awaited, or concurrent threads are accessing the same Scope (Ambient context) which is not supported. If using Task.Run (or similar) as a fire and forget tasks or to run threads in parallel you must suppress execution context flow with ExecutionContext.SuppressFlow() and ExecutionContext.RestoreFlow(). Thanks
Figured it out. ExecutionContext.SuppressFlow() does not work when you are already within Task.Run code