缓慢的导航以查看带有循环引用的模型

时间:2018-09-25 18:17:04

标签: catel

我有带有循环引用的WPF应用程序和模型,例如:

class A : ModelBase
{
    public FastObservableCollection<B> Collection {get; set;}
}

class B : ModelBase
{
    public A Parent {get; set;}
}

当我加载100多个实例并导航到另一个ViewModel调试输出时,出现以下消息:

...
20:40:36:751 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Creating new scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:752 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Custom function to create the scope is provided, creating custom scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:754 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 1
20:40:36:755 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:757 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 2
20:40:36:758 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 1
20:40:36:759 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Creating new scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:761 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Custom function to create the scope is provided, creating custom scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:762 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 1
20:40:36:763 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:765 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 2
20:40:36:766 => [DEBUG] [Catel.Runtime.Serialization.Xml.XmlSerializer] [1] Serializing property VSMC.Models.ApplicationModel.CurrentChannel as xml element 'CurrentChannel'
20:40:36:768 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:769 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 2
20:40:36:771 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 1
20:40:36:772 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:774 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 3
20:40:36:775 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:776 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 4
20:40:36:778 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:779 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 5
20:40:36:780 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Dereferencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 4
20:40:36:781 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with name 'Thread_1'
20:40:36:782 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationContextScope`1[[Catel.Runtime.Serialization.Xml.XmlSerializationContextInfo, Catel.Core, Version=5.7.0.0, Culture=neutral, PublicKeyToken=null]]' with scope name 'Thread_1', new ref count is 2
20:40:36:783 => [DEBUG] [Catel.Runtime.Serialization.SerializerBase`1] [1] Using '0' serializer modifiers to deserialize type 'VSMC.Models.ChannelModel'
20:40:36:784 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Returning existing scope for type 'Catel.Runtime.Serialization.SerializationScope' with name 'Thread_1'
20:40:36:785 => [DEBUG] [Catel.Scoping.ScopeManager`1] [1] Referencing type 'Catel.Runtime.Serialization.SerializationScope' with scope name 'Thread_1', new ref count is 5
20:40:36:786 => [DEBUG] [Catel.Runtime.Serialization.Xml.XmlSerializer] [1] Serializing property VSMC.Models.ChannelModel.Id as xml element 'Id'
...

,应用程序冻结10秒钟以上。 我做错了什么?导航时可以禁用模型序列化吗?

0 个答案:

没有答案