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 7058715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:08:44+00:00 2026-05-28T04:08:44+00:00

I have an application all done in WPF, using MvvM/Prism/Unity and Remote as datasource.

  • 0

I have an application all done in WPF, using MvvM/Prism/Unity and Remote as datasource.

I need a basic thing that on win forms is really easy, just check if the app is iddle after few minutes , and if is idle, lock the app and show the login screen.

After some search on google I ´ve found one solution that uses DllImport and another using pure Wpf methods.

I don´t know I , after I implemented the Wpf way (pls check the code below) it only works after I login into the app , if I open and click in a simple texbox or hit a search, the idle method is not fired, looks like there is something hanged in the background that makes Wpf idle routine to think that it´s doing something when it´s not.

How can I check all the services/methods/etc.. that are in memory related to may app ? callstack doesn´t show to much for me. I am affraid that or I am not calling in the correct way the remote services or I implemented something wrong on the props PropChanged events/observablecollections/etc…

Is there a better way to do this using 100% Wpf structure ?

private void CheckIdleTime()
{

    handler = delegate
    {
        DispatcherTimer timer = new DispatcherTimer();
        timer.Interval = TimeSpan.FromSeconds(5);
        timer.Tick += delegate
        {
            if (timer != null)
            {
                timer.Stop();
                timer = null;
                System.Windows.Interop.ComponentDispatcher.ThreadIdle -= handler;

                Console.WriteLine("IDLE! Lets logoff!");

                this.LockApplication();

                Console.WriteLine("logoff fired");

                System.Windows.Interop.ComponentDispatcher.ThreadIdle += handler;
            }

        };

        timer.Start();


        Dispatcher.CurrentDispatcher.Hooks.OperationPosted += delegate
        {
            if (timer != null)
            {
                timer.Stop();
                timer = null;
            }
        };
    };

    ComponentDispatcher.ThreadIdle += handler;
}
  • 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-28T04:08:45+00:00Added an answer on May 28, 2026 at 4:08 am

    There will be default window events find the idle time… i think it will be wise if we use same events for wpf or any other applications…

    following link will help you to implement it..

    Application.Idle event not firing in WPF application

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

Sidebar

Related Questions

I'm creating a WPF MVVM application. I have a long process that I want
I have this application that will recurse all folders in a given directory and
We have an application that has one or more text console windows that all
We have an application written in both C++ and .NET that installs for all
I have an application that is going to work like a p2p-software where all
I have an application that consists of a WPF UI with an infrastructure layer
I have a WPF Keyboard Application, it is developed in such a way that
I am to develop an application on windows. I have never done that before
I have a small report/logging application written in C#.NET 4.0 and WPF that I
Using the WPF DataGrid I have the need to change various display and related

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.