M
MDB
Hello All, I am trying to create a timer using the OpenNetCf to find out
when the application is on idle and have been having some problems. I have
found some example code using VB
(http://wiki.opennetcf.org/ow.asp?AppIdleTimer) however I am using C#. Here
is what my code looks like. Does anyone see what I am doing wrong?
using IMessageFilter = MyApp.AppIdleTimer;
CLASS:
public class AppIdleTimer
{
public delegate void TimeoutDelegate();
public event TimeoutDelegate AppTimeOut;
private System.Windows.Forms.Timer m_timer = new
System.Windows.Forms.Timer();
public void New(int TimeoutInterval)
{
m_timer.Tick +=new EventHandler(m_timer_Tick);
m_timer.Interval = TimeoutInterval;
m_timer.Enabled = true;
}
private void m_timer_Tick(object sender,EventArgs e)
{
AppTimeOut();
Application.DoEvents();
}
private void Dispose()
{
m_timer.Enabled = false;
}
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
public void PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m)
{
switch(m.Msg.ToString())
{
case "&H200":
case "&H201":
case "&H202":
case "&H203":
case "&H204":
case "&H205":
case "&H206":
case "&H207":
case "&H208":
case "&H209":
case "&H100":
case "&H101":
case "&H102":
case "&H103":
case "&H104":
case "&H105":
case "&H106":
case "&H107":
case "&H108":
{
m_timer.Enabled = false;
m_timer.Enabled = true;
break;
}
}
}
}
INSIDE THE MAIN
AppIdleTimer appIdle = new AppIdleTimer();
appIdle.New(10000);
appIdle.AppTimeOut += new
MyApp.AppIdleTimer.TimeoutDelegate(appIdle_AppTimeOut);
*** Getting This Error
***The best overloaded method match for
'OpenNETCF.Windows.Forms.ApplicationEx.AddMessageFilter(OpenNETCF.Windows.Fo
rms.IMessageFilter)' has some invalid arguments
***Here
ApplicationEx.AddMessageFilter(appIdle);
ApplicationEx.Run();
private void appIdle_AppTimeOut()
{
MessageBox.Show("TimeOut");
}
when the application is on idle and have been having some problems. I have
found some example code using VB
(http://wiki.opennetcf.org/ow.asp?AppIdleTimer) however I am using C#. Here
is what my code looks like. Does anyone see what I am doing wrong?
using IMessageFilter = MyApp.AppIdleTimer;
CLASS:
public class AppIdleTimer
{
public delegate void TimeoutDelegate();
public event TimeoutDelegate AppTimeOut;
private System.Windows.Forms.Timer m_timer = new
System.Windows.Forms.Timer();
public void New(int TimeoutInterval)
{
m_timer.Tick +=new EventHandler(m_timer_Tick);
m_timer.Interval = TimeoutInterval;
m_timer.Enabled = true;
}
private void m_timer_Tick(object sender,EventArgs e)
{
AppTimeOut();
Application.DoEvents();
}
private void Dispose()
{
m_timer.Enabled = false;
}
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
public void PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m)
{
switch(m.Msg.ToString())
{
case "&H200":
case "&H201":
case "&H202":
case "&H203":
case "&H204":
case "&H205":
case "&H206":
case "&H207":
case "&H208":
case "&H209":
case "&H100":
case "&H101":
case "&H102":
case "&H103":
case "&H104":
case "&H105":
case "&H106":
case "&H107":
case "&H108":
{
m_timer.Enabled = false;
m_timer.Enabled = true;
break;
}
}
}
}
INSIDE THE MAIN
AppIdleTimer appIdle = new AppIdleTimer();
appIdle.New(10000);
appIdle.AppTimeOut += new
MyApp.AppIdleTimer.TimeoutDelegate(appIdle_AppTimeOut);
*** Getting This Error
***The best overloaded method match for
'OpenNETCF.Windows.Forms.ApplicationEx.AddMessageFilter(OpenNETCF.Windows.Fo
rms.IMessageFilter)' has some invalid arguments
***Here
ApplicationEx.AddMessageFilter(appIdle);
ApplicationEx.Run();
private void appIdle_AppTimeOut()
{
MessageBox.Show("TimeOut");
}