time functions in c #

0

I am new to programming and I have learned some basic things and I am implementing them in a program to help me with what I have learned. is a game of type poo or my talking tom. Worth the redundancy is to take care of a pet and I wanted to know if there is a method to create a time, that is to say I want you to do something after a while, whether you stay home for a certain time, your hunger or mood goes down. I hope you can help me

    
asked by ShiryoStudios 14.10.2017 в 17:46
source

1 answer

0

You can use the class Timer that runs according to the time interval specified in the constructor:

Timer timer = new Timer(600000);// 600,000 = 10 minutos
timer.Elapsed += async ( sender, e ) => {
   Console.log("El gato tiene hambre!");
};
timer.Start(); // indicamos que unicie
Console.ReadKey();
    
answered by 14.10.2017 / 21:08
source