Esempio n. 1
0
        private async void ExecuteCommand()
        {
            CancelMoveMap();

            _moveMapCommand = new CancellationTokenSource();

            try
            {
                await Task.Delay(500, _moveMapCommand.Token);
            }
            catch (TaskCanceledException e)
            {
                Logger.LogMessage(e.Message);
            }

            if (!IsMapTouchDown)
            {
                var center = Map.CameraPosition.Target;
                MapMoved.ExecuteIfPossible(new Address
                {
                    Latitude  = center.Latitude,
                    Longitude = center.Longitude
                });
            }
        }
Esempio n. 2
0
        private void ExecuteMoveMapCommand()
        {
            CancelMoveMap();

            _moveMapCommand = new CancellationTokenSource();

            var t = new Task(() => Thread.Sleep(500), _moveMapCommand.Token);

            t.ContinueWith(r =>
            {
                if (r.IsCompleted && !r.IsCanceled && !r.IsFaulted)
                {
                    InvokeOnMainThread(() =>
                    {
                        MapMoved.ExecuteIfPossible(new Address {
                            Latitude = CenterCoordinate.Latitude, Longitude = CenterCoordinate.Longitude
                        });
                    });
                }
            }, _moveMapCommand.Token);
            t.Start();
        }