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

Infinte Loop Exception

3 Answers 206 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 19 Sep 2016, 10:55 AM

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?

 

 

 

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 21 Sep 2016, 02:21 PM
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.
0
Kieron
Top achievements
Rank 1
answered on 20 Apr 2017, 08:15 AM

Hi Petar,

I'm still getting reports of this issue happening.  I tested your isolated project and cannot seem to get it to break even with modifications - but I don't know how it differs really from what I've done - my xml on the grid looks like this FYI:

<Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="7" />
      <RowDefinition x:Name="mainRow" Height="*" telerik:PersistenceManager.StorageId="splitterop1" MinHeight="100"
                     MaxHeight="{Binding ElementName=Root, Path=ActualHeight, Converter={StaticResource MaxSplitterHeightWidthConverter}}"/>
      <RowDefinition Height="7" />
      <RowDefinition Height="*" />
      <RowDefinition Height="7"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="7" />
      <ColumnDefinition x:Name="mainCol" Width="*" telerik:PersistenceManager.StorageId="splitterop2" MinWidth="100"
                        MaxWidth="{Binding ElementName=Root, Path=ActualWidth, Converter={StaticResource MaxSplitterHeightWidthConverter}}"/>
      <ColumnDefinition Width="7"/>
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="7"/>
    </Grid.ColumnDefinitions>

 

Previously the only time I've seen this happen is when you attempt to move one of the gridsplitters and it just locks up and crashes the system after a minute with the InfiniteLoop Exception - on restart on the application it would usually work.  However one of our users managed to get our program in a state where it wouldn't even load the scheduler and crashed with the same exception and restarting didn't help.  I managed to grab the bin files from the user (for splitterop1 and splitterop2) and copied them to my IsolatedStorage folder and then I could replicate the error, I don't know if these files would help you to analysis the issues we're experiencing - but I can't attach them to this post?

0
Petar Mladenov
Telerik team
answered on 25 Apr 2017, 07:06 AM
Hello Kieron,

Bin / Exe file showing a program crashing wouldn't help us investigate this issue. Probably we will only see a better picture of your UI ? Instead, is it possible for you to send us more detailed application that we can test and eventually break ? To attach files you need to open a new support thread instead of forum post. 

Regards,
Petar Mladenov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
PersistenceFramework
Asked by
Kieron
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Kieron
Top achievements
Rank 1
Share this question
or