If I set my provider to the BingMapProvider and set the IsTileCachingEnabled to true, when I exit my application I still have threads running that stop my application from fully closing.
Setting the IsTileCachingEnabled to false at the start avoids the problem, but is there a way that I can clean up the threads being used to provide the cached tiles?
I am using your WPF control within a windows forms application using System.Windows.Forms.Integration.ElementHost
Thanks
Simon
Setting the IsTileCachingEnabled to false at the start avoids the problem, but is there a way that I can clean up the threads being used to provide the cached tiles?
I am using your WPF control within a windows forms application using System.Windows.Forms.Integration.ElementHost
Thanks
Simon
3 Answers, 1 is accepted
0
Accepted
Hello Simon,
Thank you for the feedback.
There is a peculiarity of using map component within a windows forms application. You should call the Dispatcher.InvokeShutdown method for closing it completely with running threads which use the tile caching.
The sample code is the following:
All the best,
Andrey Murzov
the Telerik team
Thank you for the feedback.
There is a peculiarity of using map component within a windows forms application. You should call the Dispatcher.InvokeShutdown method for closing it completely with running threads which use the tile caching.
The sample code is the following:
using
System.ComponentModel;
using
System.Windows.Forms;
namespace
WindowsFormsMap
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
protected
override
void
OnClosing(CancelEventArgs e)
{
base
.OnClosing(e);
this
.elementHost1.Child.Dispatcher.InvokeShutdown();
}
}
}
All the best,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0

Simon
Top achievements
Rank 1
answered on 19 Nov 2010, 02:34 PM
I have tried the above, and it works fine as long as you totally quit the application.
As I have an MDI type interface, the window can be closed and another one opened. In this case, I then get an exception
at MS.Internal.Data.DataBindEngine.GetDefaultValueConverter(Type sourceType, Type targetType, Boolean targetToSource)
at System.Windows.Data.BindingExpression.SetupDefaultValueConverter(Type type)
at MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32 k, Object newO, Object parent)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.AttachToRootItem(Object rootItem)
at MS.Internal.Data.ClrBindingWorker.AttachDataItem()
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
at System.Windows.Data.BindingExpressionBase.Attach(DependencyObject target, DependencyProperty dp)
at System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Data.BindingOperations.SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
at System.Windows.FrameworkElement.SetBinding(DependencyProperty dp, BindingBase binding)
at Telerik.Windows.Controls.PropertyChangedRegistrar.RegisterForNotification(FrameworkElement element, String propertyPath, DependencyProperty listener)
at Telerik.Windows.Controls.Map.MapShape..ctor()
at Telerik.Windows.Controls.Map.MapPolyline..ctor()
at Apteco.Discoverer.Plugins.Map.Visualisation.RadMapWPF.RadMapControl.SelectionLayer_Initialized(Object sender, EventArgs e) in C:\Visual Studio Projects\Discoverer\Discoverer\Apteco.Discoverer.Plugins.Map\Visualisation\RadMapWPF\RadMapControl.xaml.cs:line 336
at System.Windows.FrameworkElement.RaiseInitialized(EventPrivateKey key, EventArgs e)
at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
at Telerik.Windows.Controls.Map.InformationLayer.OnInitialized(EventArgs e)
at System.Windows.FrameworkElement.TryFireInitialized()
at System.Windows.FrameworkElement.EndInit()
at System.Windows.Controls.ItemsControl.EndInit()
at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
I don't think the actual exception is important, just the fact that we may have disposed of more than we wanted to in the InvokeShutdown
As I have an MDI type interface, the window can be closed and another one opened. In this case, I then get an exception
at MS.Internal.Data.DataBindEngine.GetDefaultValueConverter(Type sourceType, Type targetType, Boolean targetToSource)
at System.Windows.Data.BindingExpression.SetupDefaultValueConverter(Type type)
at MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32 k, Object newO, Object parent)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.AttachToRootItem(Object rootItem)
at MS.Internal.Data.ClrBindingWorker.AttachDataItem()
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
at System.Windows.Data.BindingExpressionBase.Attach(DependencyObject target, DependencyProperty dp)
at System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Data.BindingOperations.SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
at System.Windows.FrameworkElement.SetBinding(DependencyProperty dp, BindingBase binding)
at Telerik.Windows.Controls.PropertyChangedRegistrar.RegisterForNotification(FrameworkElement element, String propertyPath, DependencyProperty listener)
at Telerik.Windows.Controls.Map.MapShape..ctor()
at Telerik.Windows.Controls.Map.MapPolyline..ctor()
at Apteco.Discoverer.Plugins.Map.Visualisation.RadMapWPF.RadMapControl.SelectionLayer_Initialized(Object sender, EventArgs e) in C:\Visual Studio Projects\Discoverer\Discoverer\Apteco.Discoverer.Plugins.Map\Visualisation\RadMapWPF\RadMapControl.xaml.cs:line 336
at System.Windows.FrameworkElement.RaiseInitialized(EventPrivateKey key, EventArgs e)
at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
at Telerik.Windows.Controls.Map.InformationLayer.OnInitialized(EventArgs e)
at System.Windows.FrameworkElement.TryFireInitialized()
at System.Windows.FrameworkElement.EndInit()
at System.Windows.Controls.ItemsControl.EndInit()
at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
I don't think the actual exception is important, just the fact that we may have disposed of more than we wanted to in the InvokeShutdown
0
Accepted
Hello Simon,
Thank you for the feedback.
For your application type you can call the Dispatcher.InvokeShutdown method when the ApplicationExit event occurs. The sample code is below.
Best wishes,
Andrey Murzov
the Telerik team
Thank you for the feedback.
For your application type you can call the Dispatcher.InvokeShutdown method when the ApplicationExit event occurs. The sample code is below.
using
System;
using
System.Windows.Forms;
using
System.Windows.Threading;
namespace
MDIMap
{
public
partial
class
MapForm : Form
{
public
MapForm()
{
InitializeComponent();
System.Windows.Forms.Application.ApplicationExit +=
new
EventHandler(OnApplicationExit);
}
private
void
OnApplicationExit(
object
sender, EventArgs e)
{
Dispatcher dispatcher =
this
.elementHost1.Child.Dispatcher;
if
(!dispatcher.HasShutdownStarted)
{
dispatcher.InvokeShutdown();
}
}
}
}
Best wishes,
Andrey Murzov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF