AnsweredAssumed Answered

UI-Buttons shortly greyed out during GPS-Tracking

Question asked by EternalDOOM on Feb 8, 2018
Latest reply on Feb 12, 2018 by EternalDOOM

Hi Everybody,

 

I`ve a new question regarding a new Add-In I`m writing. It`s still for ArcGIS Pro 1.4 and SDK version 1.3.0.5861 because it extents another system on that state. Basically it monitors a local GPS device via serial port and shows the data in different ways. Everything works as desired at the moment but I`m experiencing the behaviour that my ArcGIS Pro buttons from time to time grey out /disable for a short moment.

 

I know this may have something to do that my UI-thread is blocked somehow but I can`t imagine the reason.

 

Because my Add-In has already some code in it I decided to attach the complete project as attachment. It will not run as stand-alone because it expects another add-in to be present but maybe the full code will be helpful.

 

Additionally I`ll try to explain what I`m doing in simplified pseudo code here:

 

protected GpsPanelViewModel()
{
_gpsReader = new GPSReader();
_gpsReader.RaiseGpsValuesReceivedEvent += HandleNewGPSValuesReceivedEvent;
}
private async void HandleNewGPSValuesReceivedEvent(object sender, GpsValueReceivedEventArgs e)
{
var disposable = await QueuedTask.Run(() =>
{
// Do something with received GPS-Data
// Add map point and update view model parameters for UI update
}
}
public void DoSomethingWhenGPSButtonIsClicked(object obj)
{
if (_gpsIsActive == false)
{
_gpsReader.StartReading();
}
else
{
_gpsReader.StopReading();
}
}
public class GPSReader
{
private Thread _readGpsThread;
private Thread _parseGpsThread;
private System.Threading.Timer _timerReader;
private System.Threading.Timer _timerParser;
private BlockingCollection<GpsRawData> _gpsDataBuffer;
}
public void StartReading()
{
_readGpsThread = new Thread(StartGpsReaderLoop);
_parseGpsThread = new Thread(StartGpsParserLoop);
_readGpsThread.Start();
_parseGpsThread.Start();
}

public void StopReading()
{
ClosePort();
_timerReader.Change(Timeout.Infinite, Timeout.Infinite);
_timerParser.Change(Timeout.Infinite, Timeout.Infinite);
_readGpsThread.Abort();
_parseGpsThread.Abort();
}
private void StartGpsReaderLoop()
{
_timerReader = new System.Threading.Timer((e) =>
{
GetData(); // GET data from GPS and store in _gpsDataBuffer
}, null, 0, 1000);
}
private void StartGpsParserLoop()
{
_timerParser = new System.Threading.Timer((e) =>
{
ParseData(); // Get raw data from _gpsDataBuffer and raise event when finished
}, null, 0, 500);
}

 

 

The main question for me is, where does the probem occur? Is it because I`m running two additional threads in my GPS-Reader?

Any help would be very appreciated.


Best regards

Richard

Attachments

Outcomes