Infinte Loop Exception

2 posts, 0 answers
  1. Kieron
    Kieron avatar
    6 posts
    Member since:
    Jan 2016

    Posted 19 Sep Link to this post

    So I have two gridsplitters in my app and I want to persist wherever the user drags them across sessions.  This mostly works but sometimes I seem to get this error whilst I am moving a gridsplitter and it locks and crashes the app:

    An infinite loop appears to have resulted from repeatedly invalidating the TimeManager during the Layout/Render process

    I don't know if this is a wild goose chase with the gridsplitters, but whenever I go back into the app, the gridsplitter positions revert back to their default positions and I haven't noticed it happen with any of the other controls that use the persistence framework.

     

    So on my usercontrol with both gridsplitters I have the following code :

    ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
    SplitterCustomPropertyProvider splitterPropProvider = new SplitterCustomPropertyProvider();
     
    ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RowDefinition), splitterPropProvider);
    ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(ColumnDefinition), splitterPropProvider);

     

    SplitterCustomPropertyProvider is as so:

    public class SplitterCustomPropertyProvider : ICustomPropertyProvider
     {
       public CustomPropertyInfo[] GetCustomProperties()
       {
         // Create custom property to persist the pixels property on a column/row definition
         return new CustomPropertyInfo[]
         {
           new CustomPropertyInfo("GridSplitterPixels", typeof(double)),
         };
       }
     
       public void InitializeObject(object context)
       {
       }
     
       public object InitializeValue(CustomPropertyInfo customPropertyInfo, object context)
       {
         return null;
       }
     
       public object ProvideValue(CustomPropertyInfo customPropertyInfo, object context)
       {
         GridSplitterProxy proxy = new GridSplitterProxy();
         if (context is RowDefinition)
         {
           RowDefinition row = context as RowDefinition;
           proxy.Pixels = row.ActualHeight;
           return proxy;
         }
         else if (context is ColumnDefinition)
         {
           ColumnDefinition row = context as ColumnDefinition;
           proxy.Pixels = row.ActualWidth;
           return proxy;
         }
     
         return null;
       }
     
       public void RestoreValue(CustomPropertyInfo customPropertyInfo, object context, object value)
       {
         GridSplitterProxy proxy = value as GridSplitterProxy;
     
         if (context is RowDefinition)
         {
           RowDefinition row = context as RowDefinition;
           if (proxy.Pixels == 0)
             row.Height = new GridLength(1, GridUnitType.Auto);
           else
             row.Height = new GridLength(proxy.Pixels);       
         }
         else if (context is ColumnDefinition)
         {
           ColumnDefinition col = context as ColumnDefinition;
           if (proxy.Pixels == 0)
             col.Width = new GridLength(1, GridUnitType.Auto);
           else
             col.Width = new GridLength(proxy.Pixels);
         }
       }
     
       private class GridSplitterProxy
       {
         public double Pixels { get; set; }
       }
     }

     

    The loading of the gridsplitter positions is done on the UserControl_Loaded event :

    IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
    isoStorageProvider.LoadFromStorage();

    And the saving of the positions is done on the MainWindow_Closing event :

    IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
    isoStorageProvider.SaveToStorage();

     

    Any ideas as to why I'm getting this error?

     

     

     

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 21 Sep Link to this post

    Hi Kieron,

    We made an isolated project based on your snippets.  We did not manage to receive the mentioned Exception. Could you please check out our test project and let us know if we have missed something ? Also feel free to modify the solution and send it back to us if needed. We would be glad to investigate this scenario further.

    Regards,
    Petar Mladenov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top