473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Question about a System.Threading.Timer object and the "state" object you pass to it...

Question about a System.Threading.Timer object and the "state" object you
pass to it...

Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000,
1000);

I have an array of timer objects which all fire into my OnTimer( object
state ) function very nicely. I pass in an object "o" on creation of this
timer which I subsequently get passed to me in my OnTimer function. Now in
the OnTimer function I want to modify the object "o" which I get passed back
and then have the modified version passed to me when every subsequent
interval fires.

Is this possible?
Nov 17 '05 #1
1 3263
Hi,

Why you need the timer array? If you are calling the same method and passing
the same state why not use one timer only?

Now, regarding your question, the state will persist your changes, one VERY
important thing though, the delegate will be executed in a separate thread
meaning that you have to sync. the o object, with so many timers it may be
possible that you have two thread running the delegate at the same time,

again ,try to use only one Timer

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Paul Tomlinson" <ru************@hotmail.com> wrote in message
news:Oh****************@TK2MSFTNGP12.phx.gbl...
Question about a System.Threading.Timer object and the "state" object you
pass to it...

Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000,
1000);

I have an array of timer objects which all fire into my OnTimer( object
state ) function very nicely. I pass in an object "o" on creation of this
timer which I subsequently get passed to me in my OnTimer function. Now
in
the OnTimer function I want to modify the object "o" which I get passed
back
and then have the modified version passed to me when every subsequent
interval fires.

Is this possible?

Nov 17 '05 #2

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

Similar topics

2
by: Askari | last post by:
Hi, How do for do a "select()" on a CheckButton in a menu (make with add_checkbutton(....) )? I can modify title, state, etc but not the "check state". :-( Askari
4
by: C P | last post by:
I've seen references to using an out of process state server in cases where you need to maintain session state in a web server farm. I think SQL Server will be too slow to manage the state that I...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
5
by: joeblast | last post by:
I have a Web service that gets the financial periods and hold a reference to a disconnected dataset built at initialization. Web methods work on the dataset inside the web service. Everything is...
0
by: Ismail Fatih Yıldırım | last post by:
I modified the RSACSPSample from MSDN to try out a simple commutative encryption model using RSA encryption but when i run the progrem the first encryption command works but during the second...
1
by: Steven P | last post by:
Hi, In my project I have a timer-driven state machine. The timer object are in the form. Update of controls like edit, label will be executed in some states. The state machine is in a seperate...
10
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but...
1
by: W Karas | last post by:
Virtual functions could have multiple definitions, for different object states. The prototype of a virtual member function could have an optional reserve word "for" followed by a comma-separated...
4
by: frostbb | last post by:
I have a C# WinForms treeview with 20 or so 'level 0' nodes. My users will normally have 2 of the 'level 0' branches open down to a '5th level' selected node. The users will make updates to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.