Private Const DEFAULTINTERVAL As Integer = 5 * 60 * 1000 '5 minutes as milliseconds.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'You must code the GetLastActivityTime function yourself.
Dim lastActivityTime As Date = Me.GetLastActivityTime()
'Test whether the time elapsed since the last activity is greater than the time elapsed since the last Tick event.
If Date.Now.Subtract(lastActivityTime).TotalMilliseconds > Me.Timer1.Interval Then 'There has been no activity since the last Tick.
'Send message here.
'Reset the Timer's Interval.
Me.Timer1.Interval = Me.DEFAULTINTERVAL
Else 'There has been activity since the last Tick.
'Set the Timer to Tick 5 minutes after the last activity.
Me.Timer1.Interval = Me.DEFAULTINTERVAL - Convert.ToInt32(Date.Now.Subtract(lastActivityTime).TotalMilliseconds)
End If
End Sub