Select to view content in your preferred language

GPS locks application when moving or resizing windows

4040
3
Jump to solution
02-12-2015 07:34 AM
MarkCederholm
Frequent Contributor

I have an application with a class that implements ILocationProvider to read a serial port GPS.  Reporting location updates too quickly almost guarantees that the application will lock up [control-alt-del followed by cancel will free it up again].  Sleeping the BackgroundWorker thread for 4000 ms between reads reduces the chance of this happening, but if I continually resize a child window for long enough (say several seconds), the app will inevitably lock up.

Has anyone else seen this behavior?  Is there any way I can eliminate it altogether?

UPDATE: If I use the class in a simple example, the problem doesn't crop up.  I'll update again if I can figure out how to duplicate the problem.

0 Kudos
1 Solution

Accepted Solutions
MarkCederholm
Frequent Contributor

FYI, I wrapped the port read and UI update statements into a Dispatcher.Invoke and that cleared up the problem.  Using a Task to read the serial port also works.

View solution in original post

0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor

I'd like to try and reproduce this. How often are your location updates happening?

Do you have other code executing when your extent is changing that you don't have in your simple example?

Lastly, what are you using to parse the GPS Serial Port data? (I have a library on GitHub and nuget you can use: dotMorten/NmeaParser · GitHub )

0 Kudos
MarkCederholm
Frequent Contributor

Well, as it turns out, not only was I able to create a simple example to duplicate the problem (see attached), it's not even a Runtime issue at all!  All that's required is 1) Reading a serial port, and 2) Having a child window that contains a user control defined elsewhere.  This appears to be a core WPF issue, so if I can't figure out a solution I should probably take this to a Microsoft forum.

0 Kudos
MarkCederholm
Frequent Contributor

FYI, I wrapped the port read and UI update statements into a Dispatcher.Invoke and that cleared up the problem.  Using a Task to read the serial port also works.

0 Kudos