Please see my comment to the question. You are trying to make things more complex than they have to be, especially the use of the timer. First of all, the whole idea of periodic polling of something is pretty bad wasteful. Please see my past answer for some explanations:
Application 'dashboard' for website accounts[
^].
Now, if I still had to do this polling, I would do the simple thing: create a permanently working thread doing acquisition in the loop, with some delay (
System.Thread.Sleep(delay)
) in the loop. Now, the problem is sending the acquired image to the UI. Not actually a problem. You cannot call anything related to UI from non-UI thread. Instead, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
In your case, I would use
Invoke
, not
BeginInvoke
. Why? This would throttle the thread, so it would not do unwanted image acquisition when the UI is not ready to accept it. Actually, this consideration is the key to understanding why the timer is really bad (in most cases, actually): did you ever try to take into account the cases when the handling of a timer event is not yet complete when new event is invoked? It's always better to stay away from such things.
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA