473,395 Members | 1,941 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,395 software developers and data experts.

Which Timer?

I'm glad to see that in VB 2005 I no longer have to create a form if I want
a timer like I did in VB6. I notice though, that there seems to be a Timer
component as well as two different timer classes to choose
from(System.Threading & System.Timers).
How does one decide which is most appropriate for any particular
application?
My current application is a sort of real-time data acquisition & control
system, and I need to poll an external device every 100ms or so.
TIA
Phil.


Jul 2 '07 #1
10 1533
"Phil" <N/Aschrieb
I'm glad to see that in VB 2005 I no longer have to create a form if
I want a timer like I did in VB6. I notice though, that there seems
to be a Timer component as well as two different timer classes to
choose
from(System.Threading & System.Timers).
How does one decide which is most appropriate for any particular
application?
My current application is a sort of real-time data acquisition &
control system, and I need to poll an external device every 100ms or
so.
TIA
Phil.
http://msdn2.microsoft.com/en-us/lib...e6(VS.80).aspx
http://msdn.microsoft.com/msdnmag/is...T/default.aspx
Armin
Jul 2 '07 #2
Hi Phil,

Since that your current application is a real-time data acquisition&control
system, you should use the server-based timer, i.e. System.Timers.Timer.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 3 '07 #4
>
Since that your current application is a real-time data
acquisition&control
system, you should use the server-based timer, i.e. System.Timers.Timer.
Why?

Are you not to much guessing?

Cor
Jul 3 '07 #5
Isn't that what he said in the first post? "real-time data acquisition &
control "

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uo**************@TK2MSFTNGP05.phx.gbl...
>
>>
Since that your current application is a real-time data
acquisition&control
system, you should use the server-based timer, i.e. System.Timers.Timer.
Why?

Are you not to much guessing?

Cor

Jul 3 '07 #6
Did you try to use the form timer outside a form?

No. I naturally assumed it would require a form like the VB6 version did.
Perhaps I was wrong. If the code I've written using the system timer doesn't
work very well, I'll perhaps take another look at this, thanks.
I don't know how you come at those ideas nobody told you that.
Mostly from the VB help docs. I didn't bother looking in detail at the form
based one once I discovered that there were now non-form based ones
available. The part of my application that needs the timer, doesn't have any
user interface, so a solution that doesn't involve forms seemed preferable.
But take the hard way and use one of those timer you have mentioned, I
thought that I wrote enough about it.
The Threading one did look quite complicated, and I admit that was the main
reason I decided not to bother with it. The system timer is very simple
indeed, and as far as I can see it requires about two or three lines of
code. It seems to work pretty much in the same way as the VB6 timer that I'm
used to, with the one major advantage that I can create one in code just
using new, I don't have to have a form in my dll. I can't imagine the form
one would be any simpler, even if the new version now can be used without a
form.

Thanks again for your input.
Cheers,
Phil.
Jul 13 '07 #7
>I don't have to have a form in my dll. I can't imagine the form one would
>be any simpler, even if the new version now can be used without a form.
However it is.

http://msdn2.microsoft.com/en-us/lib...er(VS.71).aspx

sample is on this page,

Cor

"Phil" <N/Aschreef in bericht
news:46**********************@ptn-nntp-reader02.plus.net...
>Did you try to use the form timer outside a form?

No. I naturally assumed it would require a form like the VB6 version did.
Perhaps I was wrong. If the code I've written using the system timer
doesn't work very well, I'll perhaps take another look at this, thanks.
>I don't know how you come at those ideas nobody told you that.

Mostly from the VB help docs. I didn't bother looking in detail at the
form based one once I discovered that there were now non-form based ones
available. The part of my application that needs the timer, doesn't have
any user interface, so a solution that doesn't involve forms seemed
preferable.
>But take the hard way and use one of those timer you have mentioned, I
thought that I wrote enough about it.

The Threading one did look quite complicated, and I admit that was the
main reason I decided not to bother with it. The system timer is very
simple indeed, and as far as I can see it requires about two or three
lines of code. It seems to work pretty much in the same way as the VB6
timer that I'm used to, with the one major advantage that I can create one
in code just using new, I don't have to have a form in my dll. I can't
imagine the form one would be any simpler, even if the new version now can
be used without a form.

Thanks again for your input.
Cheers,
Phil.

Jul 13 '07 #8

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ef**************@TK2MSFTNGP02.phx.gbl...
I don't have to have a form in my dll. I can't imagine the form one would
be any simpler, even if the new version now can be used without a form.

However it is.

http://msdn2.microsoft.com/en-us/lib...er(VS.71).aspx

sample is on this page,
The sample on this page is shorter :-)

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

Although to be fair I think it's doing a little more.
They are both very simple.

Cheers,
Phil.
Jul 16 '07 #9
I don't have to have a form in my dll. I can't imagine the form one would
be any simpler, even if the new version now can be used without a form.

However it is.

http://msdn2.microsoft.com/en-us/lib...er(VS.71).aspx

sample is on this page,
I don't see how I can use this in my dll (class library project) as the
System.Windows.Forms namespace is not defined.
Jul 17 '07 #10
>
If you don't need a user interface for this encapsulated job, don't use
the
Winforms timer.
I don't that's why I decided to use System.Timers instead. I was told though
that it would be simpler to use the form timer, and that this would work,
even without a form. I think I was misinformed.
You would need a message loop (which requires a call to
Application.Run) to use a Forms.Timer. I wouldn't create a message loop
just
for being able to use that Forms.Timer. You have to decide if you what you
have in the DLL is always part of a user interface, or, thinking the OO
abstract way, it's just an encapsulated job/thread. I don't know how you
want to implement it.
The latter is more like my situation. The DLL will eventually be used within
a larger forms application, but I like the encapsulated OO style approach
to keep the cope separate. I obviously don't want any UI elements in this
DLL if it's not necessary.
I'd probably implement the job as a class that either uses the
System.Timers.Timer (because it has an Elapsed event which is easier to
use (for me))
That's what I have done for now.
or encapsulates a thread containg a loop that does
the data acquisition and then waits by using threading.thread.sleep(100).
That sounds interesting. I might take a look at this approach in the future.
Jul 17 '07 #11

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

Similar topics

7
by: Grahmmer | last post by:
I have a few timers that are added to a form at runtime. I can handle the event fine, but I cannot identify which timer fired. Is there a way to do this? Timer Creation: -------------...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
5
by: Peter | last post by:
Hi I have a class which implements IDisposable, but it doesn't really use the Dispose method for cleaning up resources, it uses it for completing a calculation. Actually I think it seems...
3
by: zaferaydin | last post by:
Hi, I have many cyclic operations in my windows application. These operations must be called in a period of 1 second. And this operations must be run underground. in .Net there are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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
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,...

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.