Project Timeout


B

Bob Allen

I am working on an application that needs to timeout because of sensitive
information being displayed on the screen. Is there a way to flag the
application that nothing has happened for x number of seconds like a screen
saver would do? I have looked at using the mouse move events and the key
stroke events but i have so many controls in the app that this would be very
time consuming. So before undertaking this i was going to see if anyone has
a better idea?

Thanks;
Bob;
 
Ad

Advertisements

B

Bob Powell [MVP]

You could look at the Application.Idle event and do something with that.

Perhaps reset a timer to a certain amount every time the app enters the idle
state. If it stays there too long, the timer will expire and close the
window. You might need to use the threading timer instead of the message
based one.

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Blog http://bobpowelldotnet.blogspot.com
 
Ad

Advertisements

J

Jhon

Hi,

Just some untested idea, get all keyboard and mouse action trough an
implemented IMessageFilter.


Class MyMessageFilter
------------------------
public class MyMessageFilter : IMessageFilter
{
public int TimerClicks_;

MyMessageFilter (MainForm frm)
{
TimerClicks_ = 0;
}

public bool PreFilterMessage(ref Message m)
{
if ( (m.Msg >= 0x200 && m.Msg <= 0x20D)) ||
(m.Msg >= 0x100 && m.Msg <= 0x108) )
{
// Console.WriteLine("Keyboard or Mouse msg: " + m.Msg);
TimerClicks_ = 0;
}

return false; // don't block messages
}
}

Class MainForm
----------------
public class MainForm : Form
{
// put timer on form, interval to e.g. 20000 (20sec)
private MyMessageFilter MessageFilter_;
private HideableForm frmHideable_; // this is the form which
auto-hides

MainForm()
{
frmHideable_ = new HideableForm();
MessageFilter_ = new MyMessageFilter();
Application.AddMessageFilter( MessageFilter_ );
// other stuff
}

timer-eventhandler()
{
++MessageFilter.TimerClicks_;
if (MessageFilter.TimerClicks == 30) // 30*20sec = 10min
{
Timer.Stop();
frmHideable.Hide();
}
}

void ShowHideableWnd()
{
Timer.Start();
frmHideable.Show();
}

}

HTH
greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Timeout 1
Timeout property 1
Server timeout 0
Socket timeout 0
SmtpMail.Send with timeout 6
Webrequest and Timeout 1
Session timeout 2
timeout in MessageBox 2

Top