How to check IF expiration date

I have access only to .NET, and I have this situation. When creating the game (or any object in this regard), I set the expiration date (or any date, which is not very important). The date will be set at some point in the future. Now what I want to do is check to see if this date has occurred. And this should happen completely automatically. No user interaction.

My question is ...? Is it possible? And where to start?

EDIT:

I have a date stored in the database, and I want to periodically check whether this date really happened. I think that requesting a server every second to check the date stored in the database is not the most optimal solution.

+4
source share
2 answers

You must be fine ...

if(DateTime.Now > expirationDate) { /* TODO:... */ } 
+11
source

Yes, it is possible, and I do it all the time as a time freelancer. But to make the circuit more reliable, you can use the Windows registry. You calculate the hash code of your application and serialize your custom object along with the expiration date value.

  [Serializable] public class DateChecker { public string HashCode { get; set; } public DateTime ExpirationDate { get; set; } } 

Then you check the registry and check if the data has been changed. It is also stable when the user changes the date of the computer for a while. It works 100%.

0
source

Source: https://habr.com/ru/post/1335623/


All Articles