How to achieve thread safety with a timed Windows Forms update?
<p>In my C# program I'm trying to get a Panel to call OnPaint() once a second to do some Graphics drawing based on current settings. The main form uses a System.Timers.Timer to call the Panel class' update method, which ends with a Refresh() call. But when I run it, I always get an InvalidOperationExcetpion that refers to the Refresh line and says "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on." It also refers me to this MSDN page: <a href="http://msdn.microsoft.com/en-us/library/ms171728.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms171728.aspx</a></p>

<p>But all the examples on that page seem to suggest tying a new thread to a specific form event. I'm updating based on a timer, not a mouse click or similar event. Running the refresh on a separate thread sounds good to me, but I'm not sure how I'd do it (I'm good with Java, but a C# newbie). </p>
