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

problem using Timer with 2 Threading proccesses

Hello,

I am trying to measure the elapsed time between 2
processes. If I declare startTime As Double, endTime as
Double and say

startTime = Timer
....
process1
....
process2
....
endTime = Timer

this works fine. But if I use Imports System.Threading,
the program won't compile with ...=Timer. I want to
measure the elapsed time when I run the 2 processes on
different threads. Could someone explain the correct
syntax or way to accomplish this? I have tried

startTime = System.Timers.Timer

but not working. Should I use a dateTime var and then do
like a dateDiff thing?

TIA,
Rich
Nov 20 '05 #1
4 1103
dim start as long = DateTime.Now
'do something
dim end as long = DateTime.Now

dim t as TimeSpan = new TimeSpan(end - start)
't holds your info

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:1e*****************************@phx.gbl...
Hello,

I am trying to measure the elapsed time between 2
processes. If I declare startTime As Double, endTime as
Double and say

startTime = Timer
...
process1
...
process2
...
endTime = Timer

this works fine. But if I use Imports System.Threading,
the program won't compile with ...=Timer. I want to
measure the elapsed time when I run the 2 processes on
different threads. Could someone explain the correct
syntax or way to accomplish this? I have tried

startTime = System.Timers.Timer

but not working. Should I use a dateTime var and then do
like a dateDiff thing?

TIA,
Rich

Nov 20 '05 #2
sorry DateTime.Now.Ticks
"Greg Young" <gr********@planetbeach.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
dim start as long = DateTime.Now
'do something
dim end as long = DateTime.Now

dim t as TimeSpan = new TimeSpan(end - start)
't holds your info

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:1e*****************************@phx.gbl...
Hello,

I am trying to measure the elapsed time between 2
processes. If I declare startTime As Double, endTime as
Double and say

startTime = Timer
...
process1
...
process2
...
endTime = Timer

this works fine. But if I use Imports System.Threading,
the program won't compile with ...=Timer. I want to
measure the elapsed time when I run the 2 processes on
different threads. Could someone explain the correct
syntax or way to accomplish this? I have tried

startTime = System.Timers.Timer

but not working. Should I use a dateTime var and then do
like a dateDiff thing?

TIA,
Rich


Nov 20 '05 #3
I would use timespan for this, not a timer, You should find it to be more
fitting.

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:1e*****************************@phx.gbl...
Hello,

I am trying to measure the elapsed time between 2
processes. If I declare startTime As Double, endTime as
Double and say

startTime = Timer
...
process1
...
process2
...
endTime = Timer

this works fine. But if I use Imports System.Threading,
the program won't compile with ...=Timer. I want to
measure the elapsed time when I run the 2 processes on
different threads. Could someone explain the correct
syntax or way to accomplish this? I have tried

startTime = System.Timers.Timer

but not working. Should I use a dateTime var and then do
like a dateDiff thing?

TIA,
Rich

Nov 20 '05 #4
Thanks all. I have been working with .Net for only a few
months right now, so I have lots to learn. I will use the
TimeSpan thing as suggested.

Thanks for all the help.
Rich

-----Original Message-----
Hello,

I am trying to measure the elapsed time between 2
processes. If I declare startTime As Double, endTime as
Double and say

startTime = Timer
....
process1
....
process2
....
endTime = Timer

this works fine. But if I use Imports System.Threading,
the program won't compile with ...=Timer. I want to
measure the elapsed time when I run the 2 processes on
different threads. Could someone explain the correct
syntax or way to accomplish this? I have tried

startTime = System.Timers.Timer

but not working. Should I use a dateTime var and then do
like a dateDiff thing?

TIA,
Rich
.

Nov 20 '05 #5

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

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
3
by: ray | last post by:
Hi, I just wrote a windows service application to call a function of another object periodically. I used System.Server.Timer and I found that it works fine within the first 2 hours but the...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
1
by: Skip Key | last post by:
While writing a windows service, I've run into a fairly strange problem. I have a worker proc that gets fired every n seconds using System.Threading.Timer. This works fine, unless I open an...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
2
by: r norman | last post by:
Please excuse the cross-posting. This question was raised in microsoft.public.dotnet.general but hasn't been answered so I am trying where I can. There are two of us who have the same problem...
0
by: fiefie.niles | last post by:
I am having problem with thread. I have a Session class with public string variable (called Message) that I set from my Main program. In the session class it checks for the value of Message while...
5
by: CCLeasing | last post by:
For an application I'm creating I want to create a 'fake' progress bar. By fake I mean a progress bar that looks like it's doing something but actually isn't. I know philosophically this isn't...
4
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i have a main thread an another worker thread. The main Thread creates another thread and waits for the threads signal to continue the main thread. Everything works inside a ModalDialog and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...

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.