我正在制作一个应用程序,在系统空闲时,即当用户未与系统交互时,我在其中实现自动监控关闭。
我找到了一个链接:http://www.codeproject.com/KB/system/SystemIdleTimerComponent.aspx
它确实提供了知道系统何时空闲的组件。但是当我包括:
Public WM_SYSCOMMAND As Integer = &H112
Public SC_MONITORPOWER As Integer = &Hf170
<DllImport("user32.dll")> _
Private Shared Function SendMessage(hWnd As Integer, hMsg As Integer, wParam As Integer, lParam As Integer) As Integer
End Function
Private Sub button1_Click(sender As Object, e As System.EventArgs)
SendMessage(Me.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2)
End Sub
它显示此错误:跨线程操作无效:从创建它的线程以外的线程访问控件“Form1”。
最佳答案
It shows this error: Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
不要从另一个线程访问 Form1。阅读调用模式。
关于.net - VB.NET:如何知道哪个系统空闲的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8280799/