Skip to content

Thread dead lock on multiple commits #6

Description

@gravity00

When using the extension method ExecuteAndCommitAsync<T>(IUnitOfWork, Func<Task<T>>), if the commit is invoked inside the lambda, the method wont return, making a possible dead lock.

Example:

return Created(await _uow.ExecuteAndCommitAsync(async () =>
{
    var userIdentity = User.Identity.Name;

    entity.CreatedBy(userIdentity);
    entity.IndustryAgent = industryAgent;
    entity.RetailAgent = retailAgent;
    entity.Pharmacy = pharmacy;
    entity.Product = product;
    entity.Id = Guid.NewGuid();
    entity = await _uow.Orders.AddAsync(entity, ct);

    await _uow.CommitAsync(ct);

    return entity;
}, ct));    //  won't return, possible a dead lock

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions