This is a migrated thread and some comments may be shown as answers.

Using RadGrid in other thread

1 Answer 149 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
FAUSTO asked on 25 Jun 2014, 03:08 PM
In my application, I open a modal window in a separate thread with following method:

public static void ShowInSeparateThread(Type windContent, string windowTitle, int width = 900, int height = 700)
            var _viewerThread = new Thread(delegate()
                var _eventAggregg = ServiceLocator.Current.GetInstance<IEventAggregator>();
                var _win = new Window
                    Title = windowTitle,
                    DataContext = new WindowDataContext(),
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    WindowStyle = WindowStyle.None,
                    Style = Application.Current.FindResource("PopUpWindowStyle") as Style,
                    Padding = new Thickness(0),
                    Margin = new Thickness(0),
                    ResizeMode = ResizeMode.NoResize,
                    Content = ServiceLocator.Current.GetInstance(windContent),
                    Width = width,
                    Height = height,
                    ShowInTaskbar = false
                        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField,
                        null, _win, new object[] { Process.GetCurrentProcess().MainWindowHandle });
                IsBackground = true

In this window i navigate some user controls. One of that user controls contains a RadGridView binded to an ObservableCollection. When I add an item to ObservableCollection the grid items are properly notified, but when I try to remove an item from ObservableCollection i receive

The calling thread cannot access this object because a different thread owns it.

If try to change the RadGridView with native DataGrid and all works correctly. I tried also with Dispatcher.Invoke but this approach not solve my problem.

Thanks in advance for Help.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Jun 2014, 08:14 AM
Hello Fausto,

This seems very strange. The Dispatcher invocation of the CRUD operations should fix the problem. It seems this may be something entirely different. Unfortunately I cannot say what goes wrong, judging by the code snippet you have provided. Will it be possible to open a support ticket and send a small sample that we can debug, in order to determine the cause of the issue, and find a solution in the shortest terms?

Thank you in advance. 

Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question