How to invoke a new Ninject context in a timer task? It is not easy to set up a ninject scope for unitofwork. If I installed as InRequestScope (), it does not work on tasks without a request. Therefore, I am set up as below so that I can get InThreadScope for tasks:
kernel.Bind<IUnitOfWork>().To<myEntities>().InScope(ctx => HttpContext.Current ?? StandardScopeCallbacks.Thread(ctx));
But so when I set the timer
Timer timer = new Timer(_ => DelayedDisconnect(chatUser.User.AuthorizationId), null, TimeSpan.FromSeconds(10), TimeSpan.FromMilliseconds(-1));
dbContext is not updated with new database values.
public void DelayedDisconnect(string authorizationId)
{
var myChatUser = GetChatUserByClaimedIdentifier(authorizationId);
if (!myChatUser.ChatClients.Any())
So ... How do I invoke a new Ninject "context" to reflect the current state values โโof / db?
source
share