I have seen multiple older topics about using Timers in a C# code. But it doesn't work well for me. When I debug my code the null reference exception occurs.
I don't know what the best practice is for setting a timer in the code, everyone have different solutions. What I try to do is the next:
I have a mod menu (nativeUI). When I save my settings from the menu another method from another static class will be called AmbientManager.EnableAmbients();
This method needs to set the timer to start and excecute another void. Sometimes it works and the game spawns over 1000 of cars in a second, but I have the timer set to 5 seconds per spwaning vehicle..
Next code I have at the moment:
static System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();