473,749 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To Restore Form from a Timer.Elapsed Event Handler

2 New Member
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
1 2138
pbskat
2 New Member
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.T imer
Private M2Timer As Windows.Forms.T imer

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

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

Similar topics

3
1869
by: rhaley | last post by:
ugh. Okay, I need to figure out the number of milliseconds between DateTime.Now and the end of the day so that I can make changes based on the date roll-over. I need to implement a Timer so that I can process things on the Timer.Elapsed event that would happen right at the date change (unless there is a better suggestion to implement an event on the date change). DateTime isn't so friendly to this calculation. Please, any suggestions are...
2
5160
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as I am new to this. Full code below : using System; using System.Collections; using System.ComponentModel;
5
4102
by: Nathan Sokalski | last post by:
I am trying to learn how to use the System.Timers.Timer control to perform an action every certain amount of time. However, the Elapsed event doesn't want to fire, but I can't figure out why. I looked at several code examples online, but I think I was doing everything the same way they were. Does anybody have a complete example in VB.NET (the whole aspx and aspx.vb file so I know I am including everything) that I can look at? Any help would...
0
1335
by: brunft | last post by:
I was testing this with .NET Framework 2.0. Exceptions in the Elapsed event handler of a System.Timers.Timer are ignored, they are not handled by the runtime and not reported (when running outside of VS.NET) either. Ther Timer continues as if nothing happened. Is this the desired behaviour, because this would have very negative impact on analysis of unexpected errors? Am i missing any design directives concerining the exception handling...
0
1079
by: pradeep_TP | last post by:
hello all, I am planning to develop a web service which has a timer.I am planning to create different threads within that timer elapsed event. Each thread would make request to different web sites to check whether they are running or not. I want to know is it a better idea to create threads from within teh timer elaspsed event. thanks -pradeep_tp
4
11126
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts the default of True. The Elapsed event handler updates the dialog box with how long before it will close, acting as a timer itself. The dialog has a time to close property which is checked every time the Elapsed event fires. The problem I have...
3
1939
by: Rob R. Ainscough | last post by:
I have a Windows Service with a timer that use the .NET 2.0 Shell command. The Shell command returns a non-zero number but Task Manager shows the shelled exe running but there is NO visible interface (there should be one) -- I pass AppWinStyle.NormalFocus. If I execute the exact same in a Windows form test app, the Shell works flawlessly. I've tried Diagnostics.Process approach rather than Shell but have the same results -- my app...
3
2236
by: alvinwoon | last post by:
Hi guys, I find it frustrating that I need to sniff out IE to make event handler for the form's select element work across different browsers. Here's a summary of what I have right now: var select = /*get the form select element*/ var option = /*get all the option elements*/ if(document.all){
7
2236
by: wanwan | last post by:
Hi, I'm looking for a better way to do a date/time elapsed event rather than a timer elapsed event. Currently, I wrote my program to use a timer elapsed event set to 1 second, and it checks the date/time in the event. Is there a better way?
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.