How many users are we talking here? 1? Hundreds?
If there is only one, you can create a static int variable and a static DateTime variable. When the program is running, set int nTries to 0 and DateTime staticDate at this time.
Each time you display the login screen, make sure nTries <MAX_TRIES and timeSpan <5 minutes. If timeSpan is more than 5 minutes, set nTries to 0 and update staticDate to Now.
If you enjoy reading / writing text files, you can also easily read / write the number of attempts to / from a text file. In this case, you can have one row for each user if you have a small application with several users (avoid database overhead).
If you have hundreds of users, you will want to use a database. In this database, you can save each user, his last time stamp of login attempts and the number of attempts that he had.
source share