Time out in application
-
I need to implement a time-out feature in my Win 32 application developed in C#. I need to have some way that if there is not action on the application for say 10min it should ask for a re-login into the applications. Help!!! how!!!!
At first you should declare a bool, which determines whether a re-login has to be done or not and gets checked at the beginning of each handling of user interaction. Secondly start a timer, which switches the declared bool when elapsing, and reset it after each handling of an user interaction. I think the Threading.Timer class will be suitable here.
-
At first you should declare a bool, which determines whether a re-login has to be done or not and gets checked at the beginning of each handling of user interaction. Secondly start a timer, which switches the declared bool when elapsing, and reset it after each handling of an user interaction. I think the Threading.Timer class will be suitable here.
This is not at all simple.. I have the application that has about 50 dialogs all over....and many many user interaction handlers.....Do you think I will have to add timer resetter in all the user interaction handlers.... Is there any way to block all messages going to an application....main window and all subwindows...
-
This is not at all simple.. I have the application that has about 50 dialogs all over....and many many user interaction handlers.....Do you think I will have to add timer resetter in all the user interaction handlers.... Is there any way to block all messages going to an application....main window and all subwindows...
You could override the
WndProc
method of your main form or add a message filter to the message pump of your application by usingApplication.AddMessageFilter
method.
-
You could override the
WndProc
method of your main form or add a message filter to the message pump of your application by usingApplication.AddMessageFilter
method.
-
You could override the
WndProc
method of your main form or add a message filter to the message pump of your application by usingApplication.AddMessageFilter
method.
-
I did exactly that. it works fine for the main application form but when ever there is a model dialog popup the filter does not work on that window.....any idea why :confused:
Did you override the WndProc method or add a message filter? Do you pass the instance of your main form to the model dialogs (ShowDialog(this))?
-
Did you override the WndProc method or add a message filter? Do you pass the instance of your main form to the model dialogs (ShowDialog(this))?
I used message filter. I did not override the WndProc but I did override the PreProcessMessage of the main form and it is called before WndProc (but it seems specific to the form) - no luck . :(( I did use ShowDialog(this)) for the child dialog. It seems that whenever we have a modal dialog other than the main form the events of the dialog goes directly to the dialog and not pass through the main form or application queue. Is this true? :confused: Atif
-
I used message filter. I did not override the WndProc but I did override the PreProcessMessage of the main form and it is called before WndProc (but it seems specific to the form) - no luck . :(( I did use ShowDialog(this)) for the child dialog. It seems that whenever we have a modal dialog other than the main form the events of the dialog goes directly to the dialog and not pass through the main form or application queue. Is this true? :confused: Atif
I don't know exactly but here is my guess: I read again the documentation for the Application.AddMessageFilter method and found the following: "Message filters are unique to a specific thread." So I maybe the modal dialog runs with its own UI thread and therefor its message aren't detected by the filter. In this case you'll have to add a filter for every dialog. But as I said I'm not very sure about that, so open a new thread and gain from the knowledge of other CP's :)
-
I don't know exactly but here is my guess: I read again the documentation for the Application.AddMessageFilter method and found the following: "Message filters are unique to a specific thread." So I maybe the modal dialog runs with its own UI thread and therefor its message aren't detected by the filter. In this case you'll have to add a filter for every dialog. But as I said I'm not very sure about that, so open a new thread and gain from the knowledge of other CP's :)
-
I created another thread too...but it has not worked out yet...thanks a lot lot for all your help.
At first I want to apologize for the late answer. In my previous post I didn't suggest that you create another thread, but rather that for the opened modal dialog a new UI thread is created. Today, I checked this theory and it's false. The number of threads of an application stays the same when you open a modal dialog. So for me there is no obvious reason why the message filter didn't get notice of the messages for the modal dialog. Maybe you open a new thread with this specific problem, as surely another CP is able to provide a solution :)