Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Timers.Timer and threading
I am currently using the System.Timers.Timer class to call an 'OnTimer' method 20 times per second. This method then makes calls into the rest of the application.
Unfortunatley, because of the way the Timer class works, the 'OnTimer' method is executed on a different thread, but this then calls other methods in the application which are not thread-safe.
Is there any way I can cause the Ontimer method to trigger an event (or equivalent) in the same thread that the rest of the application is running in? This would obviously be far simpler than attempting to make everything else threadsafe!
Any help would be much appreciated,