An object-oriented programming language developed by Microsoft that can be used in .NET.
Hi @RogerSchlueter-7899 ,
You need to pause execution at <<STOP HERE>> in AddPoint() until the user interacts with the map and creates a point using a TaskCompletionSource.
Imports System.Threading.Tasks
Private _pointCompletionSource As TaskCompletionSource(Of Point)
Private Async Sub AddPoint()
PostAllPoints() ' Show all existing points
Points.Clear() ' Clear saved points
' Create a new TaskCompletionSource
_pointCompletionSource = New TaskCompletionSource(Of Point)()
' Wait for user to create a point
Dim newPoint As Point = Await _pointCompletionSource.Task
' Continue processing after the user adds a point
Dim win As New GeoElementParameters()
End Sub
Private Sub CreatePoint(sender As Object, e As MouseButtonEventArgs) Handles map.MouseLeftButtonUp
If Keyboard.Modifiers = ModifierKeys.Control AndAlso _pointCompletionSource IsNot Nothing Then
Dim pt As Point = map.ScreenToGeographic(e.GetPosition(map))
Points.Add(pt)
PostMark(pt, vl, Brushes.Red)
' Complete the TaskCompletionSource with the selected point
_pointCompletionSource.TrySetResult(pt)
End If
End Sub
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.