Form Timer Event - will this use up too many resources

Rx_

Nothing In Moderation
Local time
Today, 07:41
Joined
Oct 22, 2009
Messages
2,803
Will this code use up too many resources? Is there a better way or suggestion to accomplish the same thing?

On main switchboard - log the time the form loads - after form is open for 3 hours, shorten the timer interval to 5 sec. Show and flash warning label asking user to exit the application.

Users are on Citrix with remote wireless and sometimes they shut the lid turning off the PC. The Citrix Access session waits for them to log back in and restores the session. Restored sessions can be hours or even 5 days later. The problem is that a new Access application Version may have been released.

This warning ask users to exit the application. When the user logs back on, a new copy of the latest Access application Version is loaded automatically.

The resource usage with 10 to 40 concurrent people on a Citrix server is my main concern. Any suggestions are very welcome.

Code:
Option Explicit
      ' As form starts up, record the time. After form is open a specific period of time, make obnoxious lable flash and ask user to close.
      Dim StartTimer              As Date
      Dim TimeNow                 As Date
      Dim TotalTime               As Long
      'Private Const TIMER_Show_Warning = 10800    ' afer 3 hours -go to flash warning mode
      Private Const TIMER_Show_Warning = 60      ' test mode 1 min
Private Sub Form_Load()
        On Error Resume Next
        DoCmd.Restore
      StartTimer = (Now())
      Me.TimerInterval = 100000     ' checkTimer_Show_Warning                  
      Me.lblPleaseCloseForm.Visible = False   ' hide warning label 
End Sub
 
Private Sub Form_Timer()
On Error Resume Next
TimeNow = Now()
TotalTime = DateDiff("s", [StartTimer], [TimeNow])
Debug.Print "TotalTime = " & TotalTime & "  of  " & TIMER_Show_Warning
If TotalTime > TIMER_Show_Warning Then
     Me.lblPleaseCloseForm.Visible = True  ' now show label
     Me.TimerInterval = 5000                    ' flash ever 5 sec
        If Me.lblPleaseCloseForm.ForeColor <> vbRed Then
            Me.lblPleaseCloseForm.ForeColor = vbRed
        Else
            Me.lblPleaseCloseForm.ForeColor = vbBlack
        End If
End If
End Sub
 
Last edited:
When I've needed to do something similar I had a countdown displayed on the form, the countdown would reset if it detected any activity by the user (MouseMoveEvent, saving a record, etc..) after a certain amount of time passed with no activity I simply closed the database for them, no warning given.
 
Same here; for some applications a shut down works. This customer situation is different.

So a friendy reminder after 2 hours has passed will probably help them change thier way. At the 2 hour mark, the timer changes to 5 seconds, makes a label visible and flashes a warning to log out.

Regarding my question about resourse useage. So far a timer does not appear to use that much resource on the Citrix server.
 

Users who are viewing this thread

Back
Top Bottom