Pro becomes frozen after callbacks from DispatchTimer

369
2
08-24-2020 11:54 AM
RoyJackson2
New Contributor III

Greetings,

We have a custom identity integration, where the user logs into a cloud identity provider so that we can provide secure access to our API.   

Part of the requirements are to log a user out if X seconds of inactivity has elapsed.    To accomplish this, we subscribe to the map extent changed event and also editing events to reset the countdown if the user does something.   The main timer code looks like this:


_warningTimer = new DispatcherTimer();
_warningTimer.Interval = TimeSpan.FromSeconds(_timeoutSeconds);

_warningTimer.Tick += new EventHandler(initial_timeout_Has_Elapsed);
_warningTimer.Start();

The current logic in the event handler content looks like this:

await System.Windows.Application.Current.Dispatcher.Invoke(async () =>
{
   await Module1.IdentityManager.Logout();

   ProMessageWindow finalWindow = new ProMessageWindow();

   finalWindow.DialogContent.Text = "You have been logged out due to inactivity.  Please log in";

   finalWindow.Show();

   ...

   // also disables the event-activated timer reset
});

Everything is working great, until something happens in Pro, where Panes within Pro, or the entire application becomes locked. 

We have tried just calling the first command by itself.   We have tried using MessageBox versus a form.  We have tried every combination of QueuedTasks, Tasks, different kinds of timers.  

The result is we cannot click on the locked thing (like the contents pane, or the entire app, or our custom control), and we are forced to kill Pro with Task Manager.   This could be the 5th login cycle, or the 12th, or the 2nd.    There is something in the nature of what we are doing that causes Pro to become locked, perhaps waiting for a message that never comes.   There are no errors of any kind logged with our code logging.  

I am wondering if anyone else has dealt with a similar challenge, knows of why Pro 2.5 would be locking intermittently, or has suggestions for how we can hone in on the underlying cause / or a different approach.     In the end we need a timer tied to application events, and to show the user a form when they are going to be logged out.  

Thank you

Tags (2)
0 Kudos
2 Replies
KoryKramer
Esri Community Moderator
0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Kory,

 Without seeing you code, the only thing that comes to mind is that a dispatch timer will actually ensure that timer events are called on the dispatch thread.  So first thing i would remove is this:

await System.Windows.Application.Current.Dispatcher.Invoke(async () =>