Hi,
I have a small app with 2 forms. In form 1, I have a set of buttons that when clicked set the navigate URL of a web browser control in form2, show form 2 and hide form 1. The web pages shown in web browser might require the user to sign in to perform some tasks. I have a button on form 2 that allows user to go back to form 1.
The problem is that if a user logs in while in form 2 and then clicks the button to go back to form 1 (without logging out) and leaves, the next user has access to his credentials. The only way (I can think of) is to restart the application after x minutes of inactivity or if user just click on "Back" button. How can I accomplish this?
This is a desktop app that is used internally in many sites/locations. The application is always on and running.
Loading
MoPosted Jun 10, 2010, 11:45 AM
Also, I found this class library for dealing with idel time that solved my timer issue:
http://www.codeproject.com/KB/miscctrl/Application_Idle.aspx
Code:
I have two forms: StartForm and Links. There are a set of buttons in StartForm that users click to go to Links form where appropriate web page is displayed in BrowserControl in Links form.
For brevity, I removed irrelevant code and additional button properties/events:
In StartForm:
private void CustomForms_Click(object sender, EventArgs e) // This is one of the buttons
{
string sUrl = "http://SomePage.com/customsforms/";
Links links = new Links();
links.setUrl(sURL);
links.Show();
this.Hide();
}
In "Links" form:
partial class Links
{
....
private void InitializeComponent()
{
this.wbLink = new System.Windows.Forms.WebBrowser();
this.Back= new System.Windows.Forms.PictureBox(); // this is the back button that sends user to StartForm
....
}
public void setUrl(string sUrl)
{
wbLink.Navigate(sUrl);
}
.....
}
private void Back_Click(object sender, EventArgs e)
{
restartApp();
}
private void restartApp()
{
this.Close();
this.Dispose();
// Shut down the current app instance.
Application.Exit();
Process.Start(Application.ExecutablePath);
}
PJ MartinsPosted Jun 9, 2010, 2:57 PM
MoPosted Jun 9, 2010, 2:29 PM
I do have an issue with the timer though.
MoPosted Jun 9, 2010, 2:26 PM
Application.Exit();
Process.Start(Application.ExecutablePath);
As for timeout, I dropped a timer control in From2 (where the WebBrowser control is) and for testing purposes I set the timeout to 60 seconds. Works fine except with one (major) glitch: if user goes to this form and starts doing something in the web page that is displayed in the WebBrowser control, timer still goes off and application restarts. It seems clicks and keyboard use while changing stuff in the web page displayed in browser control does not count; timer still expires and in the middle of doing something application restarts.
Any way I can reset the timer in this case?
PJ MartinsPosted Jun 9, 2010, 2:20 PM