How to make jobs running offline on my game app?

44 Views Asked by At

I am developing a simple game and I faced a situation I have never studied about. Inside the game there are options and situations that something such as a construction and farming will be finished some hours or minutes after starting. for example I've started my home construction and it will take 3 hours on real life. We assume that 3 hours after it my application must run a function to finish that and update database.

Can any body suggest the best way to me to handle this situation pls?

I used Angular and ASP.Net

1

There are 1 best solutions below

1
Rup On

There's lots of ways you could do this. You could e.g.

  • write into a database table the time when the construction will complete
  • when the user next opens the game, look for all of their constructions that have completed and mark them complete. Then you don't need any background processing.

or, as you propose,

  • run a background job every minute to look for constructions that have just completed for all users in the database and mark completed.

    This looks like the latest (at time of writing) way of doing this: ASP.NET Hosted Services. But if you search for "asp.net background tasks" there are plenty of other ways.