Question about WinForms Timers and calling Control.invoke

K

Ken Varn

I have read a few messages concerning the use of windows timers and have
some questions concerning them. One of the messages hat I read stated that
timers are called on a separate thread. If this is true, is it necessary to
call Invoke when accessing forms controls within the timer function?

I was always assuming that timers functioned the same way they do in C++.
That is with a WM_TIMER message being dispatched. If the call is on a
WM_TIMER message, then it should not be necessary to call invoke because you
would already be on the context of the main window dispatch loop.

If the Timer control is not using WM_TIMER, then I would wonder why this is
so?

It is sort of hard to identify with some of these .NET layers and how they
interact at the WIN32 level if you had previously come from that
environment. I just need some clarification.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
J

Jon Skeet [C# MVP]

I have read a few messages concerning the use of windows timers and have
some questions concerning them. One of the messages hat I read stated that
timers are called on a separate thread. If this is true, is it necessary to
call Invoke when accessing forms controls within the timer function?

There are three different timer types in .NET. I suspect either you
were reading about one of the non-WinForms timers, or the author was
confused.

See http://www.pobox.com/~skeet/csharp/threads/timers.shtml
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top