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

Bounds cannot be changed while locked

11 Answers 458 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Ching-Yen
Top achievements
Rank 1
Ching-Yen asked on 24 Jul 2008, 10:48 AM
Hi,

For sometime, we are facing error code as below during app loading

Bounds cannot be changed while locked.(Telerik.WinControls)


            ' Place docking Pane
39:         _LeftDock = New _PaneLeft()


But, if we kill the application and restart, then the issue won't be appear...

Please advice.

11 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 25 Jul 2008, 09:19 AM
Hi Ching-Yen,

I was able to reproduce it. Currently, we are not quite sure what is the exactly cause for that.

It would help us if you send us a simple example to reproduce problem locally. Thank you in advance.

Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ching-Yen
Top achievements
Rank 1
answered on 26 Jul 2008, 02:56 AM
Hi,

Do you mean you able to reproduce it rite?

Another issue is...the issue does not appear consistently in my big project too... I have no clue how to reproduce it on a simple project.
0
Angel
Telerik team
answered on 28 Jul 2008, 01:07 PM
Hello Ching-Yen,

Thank you for writing.

This sounds like a multithreading issue.
The exception is shown when something in the layout is modified from a thread different than the painting one.
In the current implementation we lock the layout while painting to avoid glitches caused by animations or user code.

We intend to make our controls more thread-safe and user friendly in multithreading scenarios in the future.
However, this task is non-trivial and I cannot give you a timeframe when it will be done.

Meanwhile, you will have to avoid direct access of methods and properties from threads different than the main UI thread. In order to ensure the call is in the stack of the UI thread, you have to use Invoke() or BeginInvoke().
There is a good article in the CodeProject on the subject.

If you have further questions do not hesitate to write us.

All the best,
Angel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Arulanandham
Top achievements
Rank 1
answered on 09 Jan 2012, 12:39 PM
Hi,

We are using Q2 2010(.713) version for our application. We have faced the same problem in our application also.

System.InvalidOperationException: Bounds cannot be changed while locked.

at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)

at Telerik.WinControls.RadElement.set_Bounds(Rectangle value)

at Telerik.WinControls.UI.RadTreeView.DoLayout()

at Telerik.WinControls.UI.RadTreeView.OnLayout(LayoutEventArgs args)

at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)

at System.Windows.Forms.Control.PerformLayout()

at Telerik.WinControls.UI.RadTreeView.InvalidateLayout()

at Telerik.WinControls.UI.RadTreeView.CollapseAll(RadTreeNodeCollection nodes)

at Telerik.WinControls.UI.RadTreeView.CollapseAll()

And we have used in the UI thread only. Could you please help me how to avoid these error in this version?

Also Please clarify that whether it is good to suppressed the below exception?

 

Thanks

Arul

0
Julian Benkov
Telerik team
answered on 12 Jan 2012, 11:47 AM
Hello Arulanandham,

Thank you for contacting us.

We can not reproduce the issue by following your information. Please give us a more detailed description of used scenario, threads and synchronization logic. A simple application that demonstrates the issues will be greatly appreciated.

Please note that you have to open a new support ticket in order to be able to attach your files.

Also, please keep in mind that this version of RadTreeView control uses some part of old layout system and calculation. My advice is to upgrade your application to last Q3 2011 SP1 release and use the new version of RadTreeView control that contains greater functionality and improvements, new data engine, new layout system - flexible and customizable node elements.

I am looking forward to your reply.

Regards,
Julian Benkov
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Will
Top achievements
Rank 1
answered on 30 Jul 2013, 09:39 PM
Has anybody been able to fix this?  I'm seeing the same exception when I try to update a RadGridView.

Here is my exception:

Inner Exception 1
Type=System.InvalidOperationException
Source=Telerik.WinControls
Message=Bounds cannot be changed while locked.
StackTrace:
   at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)
   at Telerik.WinControls.RadElement.set_Size(Size value)
   at Telerik.WinControls.RadElement.SetLayoutParams(PointF newOffset, SizeF newSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.UI.RowsContainerElement.ArrangeOverride(SizeF finalSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeViewElement(RectangleF viewElementRect)
   at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeOverride(SizeF finalSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
   at Telerik.WinControls.RadElement.UpdateLayout()
   at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
   at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
   at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
   at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
   at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
   at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
   at Telerik.WinControls.Data.RadDataView`1.SyncCurrent(TDataItem item)
   at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
   at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
   at Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates)
   at Telerik.WinControls.Data.RadListSource`1.Initialize()
   at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
   at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
   at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
   at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
   at MyProject.MyWindow.<>c__DisplayClass2.<DisplayCallerInfo>b__0()

0
Tim
Top achievements
Rank 1
answered on 30 Jul 2013, 09:42 PM
Has this been resolved?  I am seeing this exception when trying to update a RadGridView:

Type=System.InvalidOperationException
Source=Telerik.WinControls
Message=Bounds cannot be changed while locked.
StackTrace:
   at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)
   at Telerik.WinControls.RadElement.set_Size(Size value)
   at Telerik.WinControls.RadElement.SetLayoutParams(PointF newOffset, SizeF newSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.UI.RowsContainerElement.ArrangeOverride(SizeF finalSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeViewElement(RectangleF viewElementRect)
   at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeOverride(SizeF finalSize)
   at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
   at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
   at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
   at Telerik.WinControls.RadElement.UpdateLayout()
   at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
   at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
   at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
   at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
   at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
   at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
   at Telerik.WinControls.Data.RadDataView`1.SyncCurrent(TDataItem item)
   at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
   at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
   at Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates)
   at Telerik.WinControls.Data.RadListSource`1.Initialize()
   at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
   at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
   at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
   at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
   at MyProject.MyWindow.<>c__DisplayClass2.<DisplayCallerInfo>b__0()
0
Peter
Telerik team
answered on 02 Aug 2013, 09:17 AM
Hello Will and Tim,

Thank you for writing.

This error indicates that the grid is not in valid state. I noticed in the error stack that you update the datasource and this probably is asynchronously (another thread or timer). I would like to clarify that all UI controls are not thread safe controls in the whole Windows Forms UI platform. Here is an
article on MSDN describing how to make thread-safe Winforms UI application. This means that RadGridView is not thread safe as well and cannot be used outside the main UI thread. In case that you are using a Timer from the System.Timers namespace you should know that this runs in the ThreadPool and your application will always produce cross-thread exception in the context of GUI. You should change the Timer object to System.Windows.Forms timer that runs in the same main thread and use it to implement the desired behavior. Also, you should use an Invoke to update the controls in cross threading scenario. For example:
if (radGridView1.InvokeRequired)
{
    radGridView1.Invoke(new MethodInvoker(() => { radGridView1.DataSource = myResults; }));//or change here something in the underlay datasource
}
else
   radGridView1.DataSource = myResults;
}

I hope this helps.

Regards,
Author nickname
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS. 
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

  Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Tim
Top achievements
Rank 1
answered on 08 Aug 2013, 01:20 PM
Thanks Peter!
0
Fernando
Top achievements
Rank 1
answered on 16 Mar 2018, 08:27 PM
I'm having the same problem, there's any news on this topic? is this issue solved?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 Mar 2018, 03:05 PM
Hello, Fernando,  

I would like to note that it shouldn't be considered as an issue. It is a specificity of the whole Windows Forms UI platform. The previously recommended approach by Peter is still valid for handling such a scenario. Feel free to use it for a multi-thread scenario.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Dock
Asked by
Ching-Yen
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Ching-Yen
Top achievements
Rank 1
Angel
Telerik team
Arulanandham
Top achievements
Rank 1
Will
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Peter
Telerik team
Fernando
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or