开发者

How to check IF expiration date occured

I have access only to .NET, and I have this situation. At creating an game (or any object for that matter), I set expiration date (or any date, that's not really important). Date is set at some point in future. Now What I want to do is to check if that date occurred. And this should happen completely automatically. Without user interactions.

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

EDIT:

I have date sto开发者_运维知识库red in database, and i want to periodically check if that date actually occurred. I guess asking server every second to check date stored in DB is not most optimal solution.


You should be able to just fine...

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


Yes, that's possible and I do it all the time as a part time freelancer. But to make the scheme more robust you can use Windows registry. You compute hash code of your app and serialize you user object together with expiration date value.

    [Serializable]
public class DateChecker
{

    public string HashCode { get; set; }

    public DateTime ExpirationDate { get; set; }

}

Then you check against registry and see if data has been tampere with. This is also stable to user's changing computer date to some past. Works 100%.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜