You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
None of the OnXxx hooks on IRegistrationBuilder are async friendly. Here's the problem I am facing right now.
OnActivated(args =>
{
var context = args.Instance;
var cts = new CancellationTokenSource();
var token = cts.Token;
context.Entities.RemoveRange(context.Entities);
context.SaveAsync(token).ConfigureAwait(false).GetAwaiter().GetResult();
context.Entities.Add(new BasicEntity { Id = 1, Name = "abc" });
context.Entities.Add(new BasicEntity { Id = 2, Name = "def" });
context.Entities.Add(new BasicEntity { Id = 3, Name = "ghi" });
context.SaveAsync(token).ConfigureAwait(false).GetAwaiter().GetResult();
}
If the idea sounds good - to add Func<T, Task> based overloads - you can assign this issue to me for implementation.
The text was updated successfully, but these errors were encountered:
This does somewhat line up with the async Disposal support we've just added. There is a certain symmetry to supporting async OnActivated as well.
I'm not sure if we'd want any other methods than OnActivated to be made async-friendly, because I don't think OnActivating, OnPreparing or OnReleasing should be implied to be something that can take a while to run.
One thing to bear in mind is that we probably don't want to implement a completely asynchronous chain throughout the Resolve path (that would be a pretty huge set of changes), and would suggest that Resolve generally can take a while to run.
I don't have any personal thoughts on this; I think it'd be a fine feature. I do think OnRelease might also need async treatment (to take advantage of async disposal in a more manual capacity, maybe). I don't know that I'd hold 5.0 up for it.
None of the OnXxx hooks on
IRegistrationBuilder
are async friendly. Here's the problem I am facing right now.If the idea sounds good - to add Func<T, Task> based overloads - you can assign this issue to me for implementation.
The text was updated successfully, but these errors were encountered: