Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread`
Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread`
15 Feb 2024, 01:37
Hi,
I'm using a System.Timers timer and on the callback function I am getting this error and it crashes:
14/02/2024 20:07:56.970 | Entering TimerBatch_Tick - Timer Callback
14/02/2024 20:07:56.970 | Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error.
14/02/2024 20:07:56.970 | CBot instance [Garys test bot, US500_SB, m1] crashed with error "Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error."
14/02/2024 20:07:57.083 | CBot instance [Garys test bot, US500_SB, m1] started.
14/02/2024 20:08:28.785 | CBot instance [Garys test bot, US500_SB, m1] process stopped responding and was terminated.
Any help appreciated as I am stuck!
PanagiotisCharalampous
15 Feb 2024, 07:03
Hi Gary,
I think the error message is clear and also explains what exactly needs to be done :) I wound suggest to use the API Timer instead.
Best regards,
Panagiotis
@PanagiotisCharalampous