|
-
Aug 29th, 2005, 09:27 PM
#1
Thread Starter
PowerPoster
Datetime Q
Just a quickie
I am trying to see how long it takes to do something
the way I am checking to see if the time elapsed is less then a second is this, but it never seems to exit the loop:
Code:
while (DateTime.Now.Millisecond < 1000)
{
this.lstMsgs.Items.Add(DateTime.Now.Millisecond.ToString());
}
this.lstMsgs.Items.Add("1 sec up");
it never seems to exit the loop.
any ideas?
-
Aug 29th, 2005, 10:09 PM
#2
Re: Datetime Q
umm you're not understanding this correctly
DateTime.Now returns the current time, so you're basically saying while the current time's milliseconds is less than 1000 repeat the loop.
I would just use the system tickcount (the value is in milliseconds... usually means the number of milliseconds since the system was rebooted)
int startTick = Environment.TickCount;
do
{
//stuff here
}while (Environment.TickCount - startTick <1000)
you could also use a TimeSpan object, or try using DateTime's Subtract() method, but I think what I just said above is fairly efficient.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Aug 29th, 2005, 10:23 PM
#3
Thread Starter
PowerPoster
Re: Datetime Q
oh yeh, of course ...
thanks Mr.Polite
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|