B
B
Bellerogrim2021-03-12 22:05:39
ASP.NET
Bellerogrim, 2021-03-12 22:05:39

How to save application state?

I'm just getting into .net and trying to figure it out. Here is my big application. And a certain object is created in it, say, an exam. The exam has a date, and a reminder must be sent three days before this date.
So what am I doing? I inherit from IHostedService, there in StartAsync I create a new Timer, where I pass DesiredTime - - DateTime.UtcNow. Well, there is a method of actually mailing, this is understandable. And I register all this disgrace during the creation of the exam through AddHostedService.

And now the actual question. What to do when restarting the application? Do I need to somehow save all my wonderful services with their parameters to the database, then load them, and re-register? Is there any automation for this? What to keep anyway? Class name and then? And in general, the class is local, utilitarian, there is no need to drag it up at all, even the very knowledge of it ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BasiC2k, 2021-03-13
@BasiC2k

Classes can be serialized to a binary stream and written as a file.
If necessary, extract and deserialize.
If there is a lot of data, it is better to store them in a database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question