Map freezes

3 posts, 0 answers
  1. Jose
    Jose avatar
    2 posts
    Member since:
    Jan 2011

    Posted 28 Jan 2011 Link to this post

    Hi,
    I'm testing RadMap. I build a window with a radmap and a listbox with locations (based on your samples).
    After a few changes in the listbox, the window freezes. I must then stop the process from visual studio.
    Bassically, i had a code like this:
    private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
           {
               ListBox lista = sender as ListBox;
               if (lista.SelectedItem == null) return;
               destino = (Location)lista.SelectedItem;
               this.radMap1.Center = destino;
           }
     
    I tried in debug and in release modes.
    I tried with both providers, bing and open.
    If I use a 'zoom effect' like in your samples (changing the last line to "ZoomOut();") the freezes occurs after 5-10 changes in the listbox. If I use the showed code, the freezes occurs after 10-50 changes.

    Thanks in advance, and excuse me if my english is not good.

  2. Jose
    Jose avatar
    2 posts
    Member since:
    Jan 2011

    Posted 01 Feb 2011 Link to this post

    This is a simplified version of my code that fails:
    MainWindow.xaml
    <Window x:Class="TelerikMapTest.MainWindow"
            Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <Grid>
            <telerik:RadMap Margin="12,12,138,12" Name="radMap1" />
            <ListBox Margin="0,12,12,80" Name="listBoxSitios" HorizontalAlignment="Right" Width="120" SelectionChanged="listBoxSitios_SelectionChanged" DisplayMemberPath="Description" />
            <Label Content="Lugar" Margin="0,0,12,12" Name="labelLugar" Height="28" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120" />
            <Label Content="Cambios:" Margin="0,0,12,46" Name="labelCambios" Height="28" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="120" />
        </Grid>
    </Window>

    MainWindow.xaml.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls.Map;
    using System.Windows.Threading;
     
    namespace TelerikMapTest
    {
        /// <summary>
        /// Lógica de interacción para MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
     
            int cuantos = 0;
     
            public MainWindow()
            {
                InitializeComponent();
     
                OpenStreetMapProvider openStreetMap = new OpenStreetMapProvider(MapMode.Road, true);
                this.radMap1.Provider = openStreetMap;
     
                Location coruna = new Location(43.375243, -8.397381); // Coruña
                coruna.Description = "A Coruña";
                Location muras = new Location(43.478983, -7.723503); // Muras
                muras.Description = "Muras";
                Location vimianzo = new Location(43.122187, -9.033623); // Vimianzo
                vimianzo.Description = "Vimianzo";
                Location malpica = new Location(43.335816, -8.810463); // Malpica
                malpica.Description = "Malpica";
                Location ferrol = new Location(43.502894, -8.222694); // Ferrol
                ferrol.Description = "Ferrol";
     
                listBoxSitios.Items.Add(coruna);
                listBoxSitios.Items.Add(muras);
                listBoxSitios.Items.Add(vimianzo);
                listBoxSitios.Items.Add(malpica);
                listBoxSitios.Items.Add(ferrol);
           }
     
            private void listBoxSitios_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                if (listBoxSitios.SelectedIndex >= 0)
                {
                    Location destino = (Location)listBoxSitios.SelectedItem;
                    labelLugar.Content = destino.Description;
                    labelCambios.Content = "Changes: " + ++cuantos;
                    this.radMap1.Center = destino;
                    this.radMap1.ZoomLevel = (this.radMap1.ZoomLevel == 12 ? 9 : 12);
                }
            }
        }
    }

    The ZoomLevel changes in the last line of listBoxSitios_SelectionChanged() makes the problem appears sooner, but even without it the problem always appears.
    After launch the app, I changed repeatly the location in the listbox with cursor keys up and down. After a few changes (in my last tests there was 65, 9, 9, 25, 5 changes, one time i reached more than 600 changes) the window freezes.

    Thanks in advance
    Jose.

    UPDATE:
    I added a button and this code:
    private void radButtonStart_Click(object sender, RoutedEventArgs e)
    {
        i = 0;
        ComponentDispatcher.ThreadIdle += new EventHandler(OnIdle);
    }
     
    private void OnIdle(object sender, EventArgs e)
    {
        if (i >= 100)
        {
            //stop
            ComponentDispatcher.ThreadIdle -= OnIdle;
        }
        else
        {
            //Change location, and sleep to force refresh.
            listBoxSitios.SelectedIndex = i % listBoxSitios.Items.Count;
            i++;
            System.Threading.Thread.Sleep(50);
        }
    }

    It allows to automate the test. Just click the button and wait until the applictation hangs. In my tests never reach the 100 iterations, always freezes before.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 02 Feb 2011 Link to this post

    Hello Jose,

    Thank you for the sample code.
    We have reproduced the problem. We have created the PITS issue to fix this problem in future releases.
    You can track it using the following link:
    http://www.telerik.com/support/pits.aspx#/public/wpf/4750

    All the best,
    Andrey Murzov
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top