By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

How To Restore Form from a Timer.Elapsed Event Handler

P: 2
Hi all,

I have an application that opens a form using frmWebQ.Show() and there it asks the user a question. Instead of replying immediately the user can choose to be reminded later (after a selectable time periods betwen 10 min and 30 days). When remind later is chosen the form activates a timer for the requested time period and minimizes itself to the task tray (Me.WindowState = FormWindowState.Minimized). Meanwhile the user can continue his work in the main form. After the time has elapsed the event handler (Timer.Elapsed()) is activated and here the form should be restored to its original size again using Me.WindowState = FormWindowState.Normal.

However, this generates the following exception (translated from German by Google): "Illegal cross-thread operation: access to the control frmWebQ was from a thread other than the thread in which it was created."

Any hint, how to overcome that? Thanks in advance.
Jan 9 '13 #1
Share this Question
Share on Google+
1 Reply

P: 2
OK, problem solved: Welcome to Billy's Belly Shop - again a uselessly confusing complexity. There are two different timer classes, obviously the difference is that one operates in a different thread:

Private myTimer As System.Timers.Timer
Private M2Timer As Windows.Forms.Timer

The first one operates in a different thread, the elapsed event is named Elapsed. The second operates in the same thread and the elapsed event is named Tick...
Jan 9 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.