Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 940159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:54:34+00:00 2026-05-15T21:54:34+00:00

I am currently developing a system that has need for a session time out

  • 0

I am currently developing a system that has need for a session time out like subsystem. It is a compact framework 3.5 application, but the principles are very similar to WinForms, so most Winforms solutions will likely work.

Here is the deal, I would like a way to throw an event which lets the MainForm, which is controlling the show, know that the user has not done anything for 20m, so call the logout function and return to the Login form.

This is a “ROUGH” implementation of what I am thinking of. To me, this seems like it smells and is far too simplistic since it assumes ALL activity is routed through a button. I think there must be a way for either the application or the system to know when it is being interacted with.

public partial class MainWindow : Window
{
    private FlowBase CurrentFlow { get; set; }

    private TimerService _service;
    private TimerService CurrentTimerService
    {
        get { return _service ?? (_service = new TimerService()); }
    }

    private TimeSpan _allowedInactivityTime = TimeSpan.FromSeconds(10);
    private TimeSpan _currentInactivityTime = TimeSpan.FromSeconds(0);

    public MainWindow()
    {
        InitializeComponent();
        GoToMainMenu();

        CurrentTimerService.OnTick += (increment) =>
                                        {
                                            if (_currentInactivityTime >= _allowedInactivityTime)
                                            {
                                                ResetInactivityTimer();
                                                GoToMainMenu();
                                            }

                                            _currentInactivityTime = _currentInactivityTime.Add(increment);
                                        };
    }

    private void ResetInactivityTimer()
    {
        _currentInactivityTime = TimeSpan.FromSeconds(0);
    }

    private void btnExit_Click(object sender, RoutedEventArgs e)
    {
        if (ccContent.Content is MainMenu)
            Close();
        else
            CurrentFlow.ExitFlow();
    }

    private void btnNext_Click(object sender, RoutedEventArgs e)
    {
        ResetInactivityTimer();
        ccContent.Content = CurrentFlow.Process(null);
    }

    private void GoToMainMenu()
    {
        var mm = new MainMenu();
        mm.OnFlowSelected += (flow) =>
        {
            CurrentFlow = flow;
            CurrentFlow.OnExit += GoToMainMenu;
            ccContent.Content = flow.Initialize();
        };

        ccContent.Content = mm;
    }
}

Thanks in advance for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:54:34+00:00Added an answer on May 15, 2026 at 9:54 pm

    Your design is correct. The natural concept of the timeout is implemented by your timer. If you are manually resetting the timer from each one of your calls, try to use any event being fired when the user interacts with the UI. Here’s a list.

    But, IMO, your solution is fine. That’s how most of the session management functions I’ve seen work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a web application that has one feature while allows input from
I am currently developing a system that holds all relevant master data like for
Problem background I am currently developing a framework of Ant Colony System algorithms. I
Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a web application based on jQuery Mobile. I would like to
I am currently developing an application and I need to be able when pressing
I am currently developing an application , that will be published on appstore. I
I'm currently developing an application which needs a lot of system and process information,
I am currently developing a charting application (for the iPhone, although that is largely
I am developing a system that has folders, groups and permissions. Permissions determine what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.