How do I kick off an entity stored procedure in EF6 async and not wait for a return?

前端 未结 2 1335
闹比i
闹比i 2021-02-19 10:09

I\'d like to just punt a call over to the SQL Server and not wait for a return. I have an imported Entity Function from a Stored Procedure that I\'d like to call asynchronously

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 10:44

    Start a new Task that creates a fresh data context and invokes that function. Just don't wait/await that task. Let it run by itself to completion.

    Make sure to log errors. Don't swallow exceptions because they might be bugs you want to know about.

    In an ASP.NET setting, be aware that the worker process can recycle at any time at all, so your background work can suddenly disappear (or be cancelled).

提交回复
热议问题