In CF v1.0 i used OpenNETCF.Windows.Forms.IMessageFilter to detect activity (or lack of) in the app. Does anybody know how to do this in CF2
Here's the code i used...
Imports
OpenNETCF.Windows.FormsPublic
Class AppIdleTimer Implements IMessageFilter 'declare timer event and delgate Delegate Sub TimeoutDelegate() Public Shared Event AppTimeout As TimeoutDelegate 'declare a system timer Private m_timer As New Timer Public Sub New(ByVal TimoutInterval As Integer) 'create an event and degalte to process each event AddHandler m_timer.Tick, AddressOf TimerProc 'setup timerm_timer.Interval = TimoutInterval
m_timer.Enabled =
True End Sub Sub Dispose() 'trash the timerm_timer.Enabled =
False End Sub Private Shared Sub TimerProc(ByVal myObject As Object, ByVal myEventArgs As EventArgs) 'fires when app timer ends RaiseEvent AppTimeout() End Sub 'this filter receives notification of activity in the app Public Function PreFilterMessage(ByRef m As Microsoft.WindowsCE.Forms.Message) As Boolean Implements OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage Select Case m.Msg Case &H200 To &H209, &H100 To &H108 ' mouse, key eventsm_timer.Enabled =
Falsem_timer.Enabled =
True End Select End FunctionEnd
Class
here's the form code
'*******************************************************************************
'Application entry point.
'This sets up the app idle timer. This timer fires when no user input is
'received for the specified period. This will fire a delgate to shut down the
'cdma connection & modem in order to conserve device power.
'*******************************************************************************
Public
Shared Sub Main() Dim config As New Settings((New SettingDefaults).Values) Dim timeOut As Double 'get timeout interval from app defaults, stored as minutes so convert to milliseconds.timeOut =
CDbl(config.GetString("TimeOut")) Dim appIdle As New AppIdleTimer(CInt(timeOut * 60000)) Dim frm As New frmMainMenu 'create a handler and assign the delegate to process the timeout events AddHandler appIdle.AppTimeout, AddressOf frm.AppTimeoutHandlerApplicationEx.AddMessageFilter(appIdle)
ApplicationEx.Run(frm)
End
Sub'*******************************************************************************
' Delegate used for App idle timer.
'*******************************************************************************
Public
Sub AppTimeoutHandler() Call runNotification() 'Show the Notify Message 'close connection 'toggle device to flight modeEnd
Sub
cheers
Paul

App Idle Timeout
AaronL
If you used the SDF 1.4 with CF v1.0, you can now use SDF v2.0 with CF v2.0:
http://opennetcf.org/sdf2
Cheers
Daniel