I am using the .NET System.Timers.Timer
in my codes. The codes run fine in the Godot editor. However, when running in the browser, the app stops with the following error obtained in the browser's console:
The Elapsed event was raised at 04:56:40.353
tmp_js_export.js:362 Unhandled Exception:
tmp_js_export.js:362 System.NullReferenceException: Object reference not set to an instance of an object.
tmp_js_export.js:362 at System.Threading.WasmRuntime.TimeoutCallback (System.Int32 id) <0x333dd70 + 0x0000a> in <filename unknown>:0
timeout callback threw a System.NullReferenceException
I am using the example codes from MSDN:
private static System.Timers.Timer aTimer;
// Called when the node enters the scene tree for the first time.
public override async void _Ready()
{
aTimer = new System.Timers.Timer(2000);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private void OnTimedEvent(System.Object source, System.Timers.ElapsedEventArgs e)
{
Console.WriteLine("The Elapsed event was raised at {0:HH:mm:ss.fff}",
e.SignalTime);
}
Any help on this issue?