Subscribe Method (SnapshotChangedEvent)
Parameters
- action
- The delegate that gets executed when the event is published.
- keepSubscriberAlive
- When false the ArcGIS.Core.Events.CompositePresentationEvent<TPayload> will maintain a weak delegate reference to the subscriber. Using a weak delegate reference relieves the subscriber from the need to unsubscribe to enable proper garbage collection.
Return Value
A
ArcGIS.Core.Events.SubscriptionToken that uniquely identifies the added subscription.
Subscribe to Location Snapshot event
private void SubscribeToSnapshotEvents()
{
SnapshotChangedEvent.Subscribe(OnSnapshotChanged);
}
private void OnSnapshotChanged(SnapshotChangedEventArgs args)
{
if (args == null)
return;
var snapshot = args.Snapshot as NMEASnapshot;
if (snapshot == null)
return;
QueuedTask.Run(() =>
{
var pt = snapshot.GetPositionAsMapPoint();
if (pt?.IsEmpty ?? true)
return;
// access properties
var alt = snapshot.Altitude;
var dt = snapshot.DateTime;
var vdop = snapshot.VDOP;
var hdop = snapshot.HDOP;
// etc
//TODO: use the snapshot
});
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.