on 2/17/07 8:20 AM, Marc Zeedar <[EMAIL PROTECTED]> wrote: >> I have the following code in a thread. All it's supposed >> to do is display the current date/time, and continually update as a >> clock. >> >> While val(Format(d.totalseconds, >> "##########"))<val(Format(theDate.totalseconds, "##########")) >> d=new date >> window1.currenttime.text=d.shortdate+" "+d.longtime >> Wend >> >> When run, I see this little app is hogging a major chunk of CPU. >> It's at >> nearly 50% of CPU on average, 17.1 MB of real ram, and more than >> 120 MB of >> VM! > > Why are you using a thread? Wouldn't a timer work better? I'd just > set a timer to fire every second. It may miss occasionally (timers > are not guaranteed time), but that's usually harmless with a clock > display. It seems to me the thread would be executing the above code > multiple times a second when the code only needs to be checked once a > second. > > Also, you're doing extra work in the code above. Why use the Format > function to compare the totalSeconds values? Just compare the > integers themselves. > > I use a timer approach for a clock display in one of my apps and it > doesn't use much CPU time at all. >
Hi, Mark-- You were right of course. I changed it to a Timer and all is well as far as CPU goes. But I broke the part that runs the alarm. I'm putting the Alarm Time into a text field, AlarmTime: AlarmTime.text=theDate.shortdate+" "+theDate.shorttime But now, I need to compare that against d=new date Unfortunately, I don't know how to convert the text back to a date to do the comparison. All My Best, Jeffrey _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
