Delaying a task in C# - db context disposed
问题 I have a situation where I need certain code to execute at a certain time (in my ASP .NET Core project). I know that delaying a task is not a great solution, but this is what I have and I'd like to know how to make it work: async Task MyMethod() { // do something // Create a new thread that waits for the appropriate time TimeSpan time = dbAppointment.ScheduledOn - TimeSpan.FromMinutes(5.0) - DateTime.UtcNow; _ = Task.Delay(time).ContinueWith(async x => await notificationManager.CreateReminder