Hi,

Assuming dt1 and dt0 (DateTime structs) represent times about or less than
one second apart, then using:

(dt1 - dt0).TotalSeconds (or TotalMilliSeconds, or dt1.Subtract (dt0))

returns 0.0 *or* 1.0 whereas on the desktop, .NET can return any value
between 0.0 and 1.0.

Is this a known issue?

Hilton

Re: TimeSpan calculation error by Hilton

Hilton
Thu Mar 06 19:42:50 CST 2008

Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping to
use it to calculate the timespan milliseconds.

Any simple way to get times less than a second? Any reason why this is so
crippled?

Hilton


"Hilton" <nospam@nospam.com> wrote in message
news:z_0Aj.19882$0w.12794@newssvr27.news.prodigy.net...
> Hi,
>
> Assuming dt1 and dt0 (DateTime structs) represent times about or less than
> one second apart, then using:
>
> (dt1 - dt0).TotalSeconds (or TotalMilliSeconds, or dt1.Subtract (dt0))
>
> returns 0.0 *or* 1.0 whereas on the desktop, .NET can return any value
> between 0.0 and 1.0.
>
> Is this a known issue?
>
> Hilton
>
>



Re: TimeSpan calculation error by Bjorn

Bjorn
Fri Mar 07 02:04:53 CST 2008

Hilton skrev:
> Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping to
> use it to calculate the timespan milliseconds.
>
> Any simple way to get times less than a second? Any reason why this is so
> crippled?
>
It depends on what you need this for.

If you just want some timing you can use DateTime.Now.Ticks
If you divide the number from Ticks by 10000 you get milliseconds.

long startTime = DateTime.Now.Ticks;
OperationSpendingTime();
long duration = DateTime.Now.Ticks - startTime;

MessageLog(String.Format("Used: {0}ms", (double)duration / 10000.0));

--
Bjorn Brox

Re: TimeSpan calculation error by Hilton

Hilton
Fri Mar 07 02:25:12 CST 2008

Nope, that doesn't work either. I either get 0 or 10000000

Hilton


"Bjorn Brox" <bpbrox@gmail.com> wrote in message
news:HZmdnQ4vNbm4ak3a4p2dnAA@telenor.com...
> Hilton skrev:
>> Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping
>> to use it to calculate the timespan milliseconds.
>>
>> Any simple way to get times less than a second? Any reason why this is
>> so crippled?
>>
> It depends on what you need this for.
>
> If you just want some timing you can use DateTime.Now.Ticks
> If you divide the number from Ticks by 10000 you get milliseconds.
>
> long startTime = DateTime.Now.Ticks;
> OperationSpendingTime();
> long duration = DateTime.Now.Ticks - startTime;
>
> MessageLog(String.Format("Used: {0}ms", (double)duration / 10000.0));
>
> --
> Bjorn Brox



Re: TimeSpan calculation error by Rüdiger

Rüdiger
Fri Mar 07 02:52:41 CST 2008

Hilton,

Environment.TickCount

Ruediger

"Hilton" <nospam@nospam.com> schrieb im Newsbeitrag
news:u41Aj.19883$0w.10173@newssvr27.news.prodigy.net...
> Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping
> to use it to calculate the timespan milliseconds.
>
> Any simple way to get times less than a second? Any reason why this is so
> crippled?
>
> Hilton
>
>
> "Hilton" <nospam@nospam.com> wrote in message
> news:z_0Aj.19882$0w.12794@newssvr27.news.prodigy.net...
>> Hi,
>>
>> Assuming dt1 and dt0 (DateTime structs) represent times about or less
>> than one second apart, then using:
>>
>> (dt1 - dt0).TotalSeconds (or TotalMilliSeconds, or dt1.Subtract (dt0))
>>
>> returns 0.0 *or* 1.0 whereas on the desktop, .NET can return any value
>> between 0.0 and 1.0.
>>
>> Is this a known issue?
>>
>> Hilton
>>
>>
>
>



Re: TimeSpan calculation error by Hilton

Hilton
Fri Mar 07 03:36:27 CST 2008

You da man!

Thanks!

Hilton
P.S. If Environment.Ticks has less than 1seccond resolution, why not
DateTime?


"Rüdiger Kardel" <rkardel@nospam.arcornews.de> wrote in message
news:fqr39a.4lo.1@news.kardel.org...
> Hilton,
>
> Environment.TickCount
>
> Ruediger
>
> "Hilton" <nospam@nospam.com> schrieb im Newsbeitrag
> news:u41Aj.19883$0w.10173@newssvr27.news.prodigy.net...
>> Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping
>> to use it to calculate the timespan milliseconds.
>>
>> Any simple way to get times less than a second? Any reason why this is
>> so crippled?
>>
>> Hilton
>>
>>
>> "Hilton" <nospam@nospam.com> wrote in message
>> news:z_0Aj.19882$0w.12794@newssvr27.news.prodigy.net...
>>> Hi,
>>>
>>> Assuming dt1 and dt0 (DateTime structs) represent times about or less
>>> than one second apart, then using:
>>>
>>> (dt1 - dt0).TotalSeconds (or TotalMilliSeconds, or dt1.Subtract (dt0))
>>>
>>> returns 0.0 *or* 1.0 whereas on the desktop, .NET can return any value
>>> between 0.0 and 1.0.
>>>
>>> Is this a known issue?
>>>
>>> Hilton
>>>
>>>
>>
>>
>
>



Re: TimeSpan calculation error by Paul

Paul
Fri Mar 07 11:12:31 CST 2008

Because ticks and the real-time clock are *NOT* the same thing. Ticks are
counted based on a 1ms interrupt. Real-time is maintained by a completely
different circuit which is in no way connected with the ticks (or
synchronized with them). The limitation on the resolution of 'time' is in
the hardware.

Paul T.

"Hilton" <nospam@nospam.com> wrote in message
news:v08Aj.13188$xq2.8704@newssvr21.news.prodigy.net...
> You da man!
>
> Thanks!
>
> Hilton
> P.S. If Environment.Ticks has less than 1seccond resolution, why not
> DateTime?
>
>
> "Rüdiger Kardel" <rkardel@nospam.arcornews.de> wrote in message
> news:fqr39a.4lo.1@news.kardel.org...
>> Hilton,
>>
>> Environment.TickCount
>>
>> Ruediger
>>
>> "Hilton" <nospam@nospam.com> schrieb im Newsbeitrag
>> news:u41Aj.19883$0w.10173@newssvr27.news.prodigy.net...
>>> Turns out dt.MilliSeconds is always zero too - that sucks. I was hoping
>>> to use it to calculate the timespan milliseconds.
>>>
>>> Any simple way to get times less than a second? Any reason why this is
>>> so crippled?
>>>
>>> Hilton
>>>
>>>
>>> "Hilton" <nospam@nospam.com> wrote in message
>>> news:z_0Aj.19882$0w.12794@newssvr27.news.prodigy.net...
>>>> Hi,
>>>>
>>>> Assuming dt1 and dt0 (DateTime structs) represent times about or less
>>>> than one second apart, then using:
>>>>
>>>> (dt1 - dt0).TotalSeconds (or TotalMilliSeconds, or dt1.Subtract (dt0))
>>>>
>>>> returns 0.0 *or* 1.0 whereas on the desktop, .NET can return any value
>>>> between 0.0 and 1.0.
>>>>
>>>> Is this a known issue?
>>>>
>>>> Hilton
>>>>
>>>>
>>>
>>>
>>
>>
>
>