46 lines
1.2 KiB
VB.net
46 lines
1.2 KiB
VB.net
Public Class ClassInactivity
|
|
Private _timer As Timers.Timer
|
|
Private _interval As Integer
|
|
|
|
Public Sub New(intervalMinutes As Integer)
|
|
_interval = intervalMinutes * 1000 * 60
|
|
_timer = New Timers.Timer(_interval)
|
|
_timer.AutoReset = False
|
|
_timer.Enabled = True
|
|
AddHandler _timer.Elapsed, AddressOf OnTick
|
|
End Sub
|
|
|
|
Public Sub Start()
|
|
If _interval > 0 Then
|
|
_timer.Enabled = True
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub Reset()
|
|
_timer.Enabled = False
|
|
_timer.Enabled = True
|
|
End Sub
|
|
|
|
Public Sub SetInterval(newInterval As Integer)
|
|
_timer.Interval = newInterval
|
|
_interval = newInterval
|
|
End Sub
|
|
|
|
Private Sub OnTick()
|
|
' Der User wird ausgeloggt
|
|
ClassUser.LogoutUser()
|
|
|
|
Dim result As DialogResult = MessageBox.Show("Sie wurden aufgrund von Inaktivität ausgeloggt. Möchten Sie sich wieder anmelden?", "Inaktivität", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
If result = DialogResult.Yes Then
|
|
ClassInit.InitUserLogin()
|
|
MsgBox("Sie wurden wieder eingeloggt")
|
|
Else
|
|
MsgBox("Die Anwendung wird beendet")
|
|
Application.Exit()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|