Skip to content

Not working with async/await #5

@fubar-coder

Description

@fubar-coder

The _scopeStack of UnitOfWorkScopeManagerBase<TContext> has a ThreadStatic attribute, which doesn't work together with async/await. The solution is to use AsyncLocal instead.

Please take a look at this example for more information:

https://gist.github.com/JoshKeegan/66d649f6c5cc127d2f4057133d7d5bdc

You also link to the following article, which contains this warning:

Async Warning

Updated 2018-04-20 The code here was written before async use was wide spread and doesn’t work with async. The code relies on thread static variables, which will fail when a request is processed asynchronously, being handled by different threads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions