New topic: Timer vs Thread
<http://forums.realsoftware.com/viewtopic.php?t=30603> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message Paul Burnside Post subject: Timer vs ThreadPosted: Thu Oct 22, 2009 12:24 pm Joined: Mon May 08, 2006 8:50 pm Posts: 506 May seem a silly question but here it is. I need to have a 1 second time delay that will yield to other functions such as key strokes etc while in the delay period. I also need to call the time delay from the CellBackgroundPaint event ( I think ) so I can modify graphics in a listbox on a repetative, one second, basis. First, I need an opinion on which method would be best.....Timer or Thread. Secondly, how can I call a delay function from the CellBackgroundPaint event and return to the calling code at the end of the delay? Just fishing for some comments. I've played a little with using a thread but it seems I'd have to use a Timer within the Thread anyway so why not just use a Timer by itself. Can this be done from inside the CellBackgroundPaint event? Any comments would be appreciated. Top timhare Post subject: Re: Timer vs ThreadPosted: Thu Oct 22, 2009 1:19 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 6608 Location: Portland, OR USA I think you've got the control sequence backward. The timer would trigger a CellBackgroundPaint, not the other way around. (Use ListBox.InvalidateCell to trigger a repaint.) Depending on how accurate you need the timing to be, you could set the timer to fire more frequently and check the amount of time elapsed since the last refresh. Otherwise, the timer may fire after more than exactly 1 second, and a one second interval will cause the timing to shift out of phase with a strict one second repeat. If approximately one second is good enough, then don't worry about it. Tim Top Paul Burnside Post subject: Re: Timer vs ThreadPosted: Thu Oct 22, 2009 1:50 pm Joined: Mon May 08, 2006 8:50 pm Posts: 506 Tim, Thanks for the response. You're exactly right...as I did have the control sequence backwards. Also, the timer need not be precise so no worry there. Finally, thanks for reminding me of the "ListBox.InvalidateCell" method. I keep forgetting about that. Thanks again. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
