Mahdi
Mahdi

Reputation: 11

Scheduling jobs in ASP.NET MVC

I want to create an ASP.NET MVC app with which I want to send some messages to my telegram channel via Telegram Bot API at a certain time automatically, even when I am not in my web app.

For example I want to send one of my messages on these dates:

2018/03/23, 2018/03/28, 2018/04/05

I want to send these messages without any human help and automatically but I do not know how to do it. Now I can send my message at this time, not at the later time and automatically.

Upvotes: 0

Views: 206

Answers (3)

Vikas
Vikas

Reputation: 39

Why you want to implement the same into Asp.Net MVC..? In MVC you can't shedule the task, still if you can but it not proper way of implementation.

As per your requirement you should have to go with windows service, this will be a perfect approach for your requirement implementation.

Upvotes: 0

Onyx Caldin
Onyx Caldin

Reputation: 299

You should take a look at HangFire which is available as nuget packages and may suit your needs perfectly.

An easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required. Backed by persistent storage. Open and free for commercial use.

Which allows to create :

Delayed jobs are executed only once too, but not immediately, after a certain time interval.

var jobId = BackgroundJob.Schedule(
    () => Console.WriteLine("Delayed!"),
    TimeSpan.FromDays(7));

Upvotes: 2

dsdel
dsdel

Reputation: 1062

With .Net native there is no such option available (at least I am not aware of it).

Either create a windows service which is monitoring the database and performing the operations.

Or, a little bit more simple, create a scheduled task which is running every 5 minutes eg. and executing a console application.

Upvotes: 0

Related Questions