当我在我的应用程序上工作最多 15 分钟时,然后关闭我的应用程序。 Vb.net
when i am not worked upto 15 mins on my application then close my application. Vb.net
我正在使用 Visual Studio 2015。使用 VB.net 创建一个应用程序
我有要求的自动退出申请。当我在我的应用程序上工作最多 15 分钟时,然后关闭我的应用程序。
谢谢
你可以这样做
Public Class Form1
Dim app As Application
Private Sub MainWindow_Loaded(sender As Object, e As EventArgs) Handles Me.Load
Dim aTimer As System.Timers.Timer
aTimer = New System.Timers.Timer()
aTimer.Interval = 5000
' Hook up the Elapsed event for the timer.
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Start the timer
aTimer.Enabled = True
End Sub
并且在 raise 事件中你可以这样写...
Private Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
'Environment.Exit(0) - closes without a problem
'Application.Exit() - closes without a problem
'closes without a problem.
app.Exit()
'Me.Close() - System.InvalidOperationException
End Sub
我正在使用 Visual Studio 2015。使用 VB.net 创建一个应用程序 我有要求的自动退出申请。当我在我的应用程序上工作最多 15 分钟时,然后关闭我的应用程序。 谢谢
你可以这样做
Public Class Form1
Dim app As Application
Private Sub MainWindow_Loaded(sender As Object, e As EventArgs) Handles Me.Load
Dim aTimer As System.Timers.Timer
aTimer = New System.Timers.Timer()
aTimer.Interval = 5000
' Hook up the Elapsed event for the timer.
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Start the timer
aTimer.Enabled = True
End Sub
并且在 raise 事件中你可以这样写...
Private Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
'Environment.Exit(0) - closes without a problem
'Application.Exit() - closes without a problem
'closes without a problem.
app.Exit()
'Me.Close() - System.InvalidOperationException
End Sub