Timer Class – Generates an event after a set interval, with an option to generate recurring events.
This is easy to use, let’s see one simple example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | using System; using System.Timers; public class Program { public static void Main() { Timer timer = new Timer(200); timer.Elapsed += Timer_Elapsed; timer.Start(); while (true) { // Infinite loop. } } private static void Timer_Elapsed(object sender, ElapsedEventArgs e) { // Use SignalTime. DateTime time = e.SignalTime; Console.WriteLine("TIME: " + time); } |
The result is this:
1 2 3 4 5 6 7 8 9 10 11 | TIME: 9/2/2021 7:42:16 PM TIME: 9/2/2021 7:42:17 PM TIME: 9/2/2021 7:42:17 PM TIME: 9/2/2021 7:42:17 PM TIME: 9/2/2021 7:42:17 PM TIME: 9/2/2021 7:42:17 PM TIME: 9/2/2021 7:42:18 PM TIME: 9/2/2021 7:42:18 PM TIME: 9/2/2021 7:42:18 PM TIME: 9/2/2021 7:42:18 PM Fatal Error: Execution time limit was exceeded |
This : Fatal Error: Execution time limit was exceeded is a protected issue from
This online tool comes with these restrictions:
Currently the Sandbox has the following limits per single run:
Code Block Size – 100K
Console Output Size -100K
Execution Time – 5s
Memory – 10MB
Disk Space – 1MB
.NET Restrictions to prevent malicious code
No access to File System IO
No external internet access
In Console Project Type – Main function must be public inside public class