KmlReader in Background thread

2 Answers 75 Views
Map
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 20 Dec 2022, 02:02 PM | edited on 20 Dec 2022, 02:04 PM

var frameworkElements = KmlReader.Read(memoryStream);

I have a list of the elements (which in the initial stage are not displayed on the map) and I want to have a BusyIndicator until loading.

That is, until I performed the KmlReader.Read(memoryStream), the list in the picture will be a square without data, so I want a BusyIndicator

But the KmlReader works on the UI thread, so this cannot be done.

Is there a way to overcome this?

Is there a way to make this line in the background thread?

 

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Dec 2022, 08:52 AM

Hello Ohad,

You can use the AsyncKmlReader with VisualizationLayer.  The following article also shows a BusyIndicator example:

https://docs.telerik.com/devtools/wpf/controls/radmap/features/visualization-layer/reading-map-shapes#reading-files 

Regards,
Petar Mladenov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 26 Dec 2022, 09:25 AM | edited on 26 Dec 2022, 09:26 AM

var path = @"C:\Users\Downloads\test.kml";

var xDocument= XDocument.Load(path);

MemoryStream ms = new MemoryStream();

xDocument.Save(ms);

ms.Position = 0;

var asyncKmlReader = new AsyncKmlReader();

asyncKmlReader.ReadAsync(memoryStream);

In this code AsyncKmlReader does not contain any items, if I change it to KmlReader then I have items.

 

I would like to understand where the problem is here

Stenly
Telerik team
commented on 29 Dec 2022, 08:56 AM

The reason for this behavior is that the AsyncKmlReader will start reading the KML file asynchronously. Once it is done reading the file, the PreviewReadShapeDataCompleted event of the AsyncKmlReader instance will occur. Through its event arguments, the items can be retrieved (utilize the Items property of the event arguments).

With this being said, I hope the provided information will be of help to you.

Tags
Map
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Petar Mladenov
Telerik team
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or