473,405 Members | 2,210 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,405 software developers and data experts.

Using Timer to Reduce Flicker

675 512MB
I am comparing picture names in a Folder with the names in a table, in order to find files that are not referenced within the database. I call these "Orphans"

This routine is imbedded in a large program, and I am only presenting a small fraction of the code. All variables are declared. Those beginning with str... are String, beginning with ii... are Long, lbl... are Labels, etc.

The routine worked, but the image flickered because line 22 of the code is executed ~80K times. To reduce the flicker, I inserted the lines marked as "Added line". The code still works, but the label on the form (lblDisplay) isn't displayed until cmdFindOrphans_Click exits. As a matter of fact, the timer event appears not to be triggered, as the function (code lines 28-30) is never executed.

A toggle breakpoint at line 25 has TimerInterval = 250, as it should. Before you ask, yes, the property sheet for the form has [Event Procedure], and the [. . .] gets me to the code corresponding to line 28.

Is there something I am missing here?


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     . . . . 
  3.     Me.TimerInterval = 0 'Added line
  4. End Sub 
  5.  
  6. cmdFindOrphans_Click
  7.     iiRecCt = 0
  8.     iiOrphanCt = 0
  9.     lblDisplay.Caption = ""
  10.     Set dbs = CurrentDb
  11.     Set rst = dbs.OpenRecordset("SELECT . . .")
  12.  
  13.     strFile = Dir(strPath & "\*.*")
  14.     Me.TimerInterval = 250 'Added line
  15.     Do Until strFile = ""
  16.         iiRecCt = iiRecCt + 1
  17.         If IsOrphan(arg1, . . .) = True Then
  18.             iiOrphanCt = iiOrphanCt + 1
  19.             . . . .
  20.         End If
  21.         lblDisplay.Caption = "Checked=" & iiRecCt & "   Orphans=" & iiOrphanCt
  22.         'Me.Repaint 'Original line
  23.         strFile = Dir()
  24.     Loop
  25.     Me.TimerInterval = 0 'Added line
  26. End Sub
  27.  
  28. Private Sub Form_Timer() 'Added line
  29.     Me.Repaint 'Added line
  30. End Sub 'Added line
  31.  
OldBirdman
Jan 12 '08 #1
6 4197
missinglinq
3,532 Expert 2GB
I've frequently seen the use of the Timer given as the cause of screen flicker, but I've never heard of it being used to suppress screen flicker! The problem here, I expect, for the label not appearing, is that you're repainting the screen too frequently. Timer Interval = 1000/second, so an Interval of 250 means the screens repainting every 1/4 of a second.

Linq ;0)>
Jan 12 '08 #2
OldBirdman
675 512MB
I could have no label, and no counters. The problem would go away. I would have to substitute the 'hourglass' for the cursor, to show I was actually doing something, and not just looping or idle.

I had flicker when I did not have the timer. I checked 4,000 files in about 9 seconds, so the repaint rate would have been about 400/second, somewhat faster than 4/second.

I could live with the flicker, but I felt that the repaint might be quite expensive, and reducing the number of times by a factor of 100 might speed it up.

OldBirdman
Jan 13 '08 #3
FishVal
2,653 Expert 2GB
Hi, OldBirdman.

To the best of my knowledge events (including that from form timer) are not asynchronous in VBA. No timer event will be fired while code is running.
You may try to use win timer but this maybe a bit unsafe.

Regards,
Fish
Jan 13 '08 #4
ADezii
8,834 Expert 8TB
Hi, OldBirdman.

To the best of my knowledge events (including that from form timer) are not asynchronous in VBA. No timer event will be fired while code is running.
You may try to use win timer but this maybe a bit unsafe.

Regards,
Fish
I do believe that FishVal is right on this one, as long as code execution is contained within the Do...Loop, the Timer() Event will never fire.
Jan 13 '08 #5
OldBirdman
675 512MB
Thank you! Not sure what "asynchronous" is, but that's OK.

Within my loop, I inserted an iiCounter and incremented for each iteration of the loop. Then:
Expand|Select|Wrap|Line Numbers
  1. . . . 
  2. If iiCounter mod 1000 = 0 then 
  3.     lblStatus.Caption = "Checked=" & iiCounter & " --- Found=" & iiFound 'Checked=3000 --- Found=8'
  4.     Me.Repaint 
  5. End If
  6. . . . 
  7.  
I can adjust the speed of the display update by tinkering with the 'mod' value. I consider this problem solved. Thank you all again.

OldBirdman
Jan 15 '08 #6
FishVal
2,653 Expert 2GB
Not a problem.
Good luck.
Jan 15 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael | last post by:
Here is my problem: I have a MDI application and when I load my child forms I get alot of flicker. I have tried to implement double buffering : Public Sub New() MyBase.New() 'This call is...
4
by: Marek Mänd | last post by:
This seems an IE issue only: 4253 bytes testcase: http://www.hot.ee/idaliiga/testcases/ieselect/bnlinkingselectinmsie.htm Can one have 1) a mouseover/mouseout element on TBODY 2) change in...
1
by: Christopher Weaver | last post by:
I've used a Time.Tick event to do this: pictureBox1.Location = new Point(PictureLeft, 0); The speed with which the change takes place increases as I reduce the value of Timer.Interval until it...
2
by: karunakar | last post by:
Hi All I dont want to expire the applicatoion Once login the application i dont want to expire the application Presently iam doing using cookies this is not working fine Please help me out ...
3
by: Per Dunberg | last post by:
Hi all, I have to develop a "skinned" application and I have a problem with the graphics. When a form is loaded and displayed there's aways a flicker where all the controls are located on the...
7
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be...
1
by: Wayne | last post by:
I've noticed some screen flicker when using Access 2003 under Vista and I'm curious as to whether this is a bug or peculiar to my machine. In design view, if I make changes to a form and then...
4
by: Frank Rizzo | last post by:
Hello, I inherited a large Winforms project that is suffering from excessive flicker when switching between portions of the application. I've noticed that most parts of the application (user...
9
by: =?Utf-8?B?TWlrZTk5MDA=?= | last post by:
Hello, I am wondering if it is a good idea to use GC.Collect() in a timer. For example, timer is fired every 5 minutes and calls GC.Collect(). In our server app the memory goes to 600MB and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.