I have a method which is worked asynchronous by a BackgroundWorker. Within this method, some code loops infinitly with an interval of 1000 ms.
Within this code, depending on some value, an event is dispatched. As far as I have understood this, this event runs in the same thread as the code from which it has been raised.
But what I want is, that this event runs in the same thread as the object which holds the BackgroundWorker.
How do I achive this?
You would be better off using a
Timerto schedule recurring events. If this is a Windows Forms application (which I’ll assume it is since you want to run it in the context of the “owning” thread) you should use aSystem.Windows.Forms.Timerinstance.