X分钟后自动注销应用程序 [英] Auto logoff for an application with X minutes

查看:104
本文介绍了X分钟后自动注销应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



一段时间后,我试图在应用程序的自动注销上编写代码.但是不确定我应该如何开始.

但是我得到了下面的代码,但是有一个错误(例如:

System.Windows.Interop.

Hi,

I am trying to write a code on auto logoff for an application after certain perioed of time. But not sure how should i start on it.

But I got below code, but there is an error (example:

System.Windows.Interop.

 

System.Windows.Interop不是Windows的成员,并且System.Windows.Threading不包含任何公共成员),我不知道应该如何修复它并将其合并到我的应用程序代码中.

需要一些帮助.谢谢.

System.Windows.Interop is not a member of Windows and System.Windows.Threading is not doesn't contain any public member) and i wonder how should it get fix and merge into my application code.

Need some help. Thank you.

Imports System 
Imports System.Collections.Generic 
Imports System.Linq 
Imports System.Text 
Imports System.Windows.Threading 
Imports System.Windows.Forms 
Imports System.Threading 

Namespace AutoLogOffInWPF 
    Class AutoLogOffHelper 
        Shared _timer As System.Windows.Forms.Timer = Nothing 
        Private Shared _logOffTime As Integer 
        Public Shared Property LogOffTime() As Integer 
            Get 
                Return _logOffTime 
            End Get 
            Set(ByVal value As Integer) 
                _logOffTime = value 
            End Set 
        End Property 
        
        Public Delegate Sub MakeAutoLogOff() 
        Public Shared Event MakeAutoLogOffEvent As MakeAutoLogOff 
        Public Sub New() 
            
        End Sub 
        Public Shared Sub StartAutoLogoffOption() 
            AddHandler System.Windows.Interop.ComponentDispatcher.ThreadIdle, AddressOf DispatcherQueueEmptyHandler 
        End Sub 
        Private Shared Sub _timer_Tick(ByVal sender As Object, ByVal e As EventArgs) 
            If _timer IsNot Nothing Then 
                RemoveHandler System.Windows.Interop.ComponentDispatcher.ThreadIdle, AddressOf DispatcherQueueEmptyHandler 
                _timer.[Stop]() 
                _timer = Nothing 
                    
                RaiseEvent MakeAutoLogOffEvent() 
            End If 
        End Sub 
        
        Private Shared Sub DispatcherQueueEmptyHandler(ByVal sender As Object, ByVal e As EventArgs) 
            If _timer Is Nothing Then 
                _timer = New System.Windows.Forms.Timer() 
                _timer.Interval = LogOffTime * 60 * 1000 
                AddHandler _timer.Tick, AddressOf _timer_Tick 
                _timer.Enabled = True 
            ElseIf _timer.Enabled = False Then 
                _timer.Enabled = True 
            End If 
        End Sub 
        
        Public Shared Sub ResetLogoffTimer() 
            If _timer IsNot Nothing Then 
                _timer.Enabled = False 
                _timer.Enabled = True 
            End If 
        End Sub 
        
    End Class 
End Namespace 

推荐答案

请在此处查看:

http://社交.msdn.microsoft.com/Search/zh-CN/?query = logoff& rq = meta:Search.MSForums.ForumID(0f60fa48-1ceb-41ee-a10a-0dfcee7e19bd)& rn = Visual + Basic + General + Forum


这篇关于X分钟后自动注销应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆