Search code examples
asp.net-core-signalr

Triger SignalR Core method at specific time


I am trying to create a scheduled action for signalR hub method. In ASP.NET I did this

private async System.Threading.Tasks.Task<object> ScheduleAction(Action action, DateTime ExecutionTime)
    {
        var t = System.Threading.Tasks.Task.Run(
            async () =>
            {
                await System.Threading.Tasks.Task.Delay((int)ExecutionTime.Subtract(DateTime.Now).TotalMilliseconds);
                action();
            });
        return t;
    }
}

Probably not the best solution but it worked I would pass Hub method as action as well as DateTime on when to trigger and it worked. Now in ASP.NET Core I get error that says I can not access object that has been disposed and now I have problem. I need a way to trigger a Hub method at specific time.

Thank you


Solution

  • I got the answer on GitHub. It is not possible to manualy call hub method in asp.net core. More details here: Triger SignalR Core server method at specific time