473,487 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Timer on form not affected by other thread with no error

Situation:

Timer1 on main form needs to be stopped during a thread action.

Programming in second thread:

timer1.enabled = false

Action:

1. No error
2. Timer is not stopped.

Well, thanks!

There is no .InvokeRequired available for a timer control
There is no error message
There is no action

What could be worse than nothing happening and no message saying it did
not happen? Oh, I know, a message saying "The action was not
performed." with no information about what action was not performed.

Yes, I fixed it by creating a global variable and setting it and having
the timer tick code look at the global variable to see if it should
proceed or exit. Very stupid and wasteful but, at least, it works.

There seems to be an idea that threads should not change global
variables which are to be viewed by code outside the thread but I see no
other way to proceed. Spawning a form would require the same global
because I don't want to use ShowDialog on it so the main thread UI will
continue to work.

Mike

Jun 27 '08 #1
2 993
Ju********@home.net wrote in news:nvjn04ljmi00obv3ihrl31kl1f6moqv14s@
4ax.com:
Timer1 on main form needs to be stopped during a thread action.

Programming in second thread:

timer1.enabled = false

Action:

1. No error
2. Timer is not stopped.
How are you getting a reference to the timer object?

The thread obviously needs to have access to the timer to stop it?

--
sp**********@rogers.com (Do not e-mail)
Jun 27 '08 #2
Hi,

You know that there are 3 timers where the system.Threading.Timer is for
working with threads.

http://msdn2.microsoft.com/en-us/lib...ing.timer.aspx

Cor
<Ju********@home.netschreef in bericht
news:nv********************************@4ax.com...
Situation:

Timer1 on main form needs to be stopped during a thread action.

Programming in second thread:

timer1.enabled = false

Action:

1. No error
2. Timer is not stopped.

Well, thanks!

There is no .InvokeRequired available for a timer control
There is no error message
There is no action

What could be worse than nothing happening and no message saying it did
not happen? Oh, I know, a message saying "The action was not
performed." with no information about what action was not performed.

Yes, I fixed it by creating a global variable and setting it and having
the timer tick code look at the global variable to see if it should
proceed or exit. Very stupid and wasteful but, at least, it works.

There seems to be an idea that threads should not change global
variables which are to be viewed by code outside the thread but I see no
other way to proceed. Spawning a form would require the same global
because I don't want to use ShowDialog on it so the main thread UI will
continue to work.

Mike
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4006
by: Anthony Boudouvas | last post by:
Hi to all, i have a form with 2 System.Windows.Forms.Timer objects. One fire every 5 seconds and the other every 10 seconds, the both take actions in two hashtables declared in same form. ...
8
2765
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
13
9685
by: Diego_Atos | last post by:
I've create a "stupid" animation. A simple label that bounce on borders of my form. Motion is ruled by a timer that set the timing of every steps. If I set the interval at "1000" it works...
6
2836
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
7
2660
by: Mike Eaton | last post by:
Hi All, I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user...
5
9853
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
4
3060
by: Nijazi Halimaji | last post by:
Hi everybody I have created a new timer object WithEvents tmr_check As New System.Timers.Timer On my form_Load-Event I activated the timer... Then I made a label on my form and putted on...
5
3237
by: Peted | last post by:
Just some threading questions 1. in a MDI app if you have multiple child forms, does each child form run in its own thread ? Eg do you get error trying to update one control on form1 from...
3
3816
by: Beemer Biker | last post by:
Unaccountably, I cannot re-enable a timer from an background thread. The disable works fine, I just cannot get it to start back up. There is no method "InvokeRequired" like there is for...
0
7105
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,...
0
6967
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...
0
7132
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,...
1
6846
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...
0
5439
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,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
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 ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.