Any "gotchas" using the Freezable class outside of WPF?

I read on concurrency and looked at things from a more "exact" point of view. WPF (or, in fact, System.Windows.Freezable and others) has a class that can be "frozen". Has anyone tried using this outside of WPF / Silverlight, and would it be better to use this, or quit your own / use someone else's? I know there are some good ones.

+3
source share
2 answers

You cannot use the Freezable type in System.Windows outside of WPF.

The reason for this is that you are creating a dependency on WindowBase.dll (or where Freezable is defined). And such a link should not exist in "model projects" without direct access to the user interface.

However, you can easily create your own Freezable base class.

I used the following interface in an application where I wanted to create thread-safe objects that required complex initiation (these were circular links):

public interface IFreezable
{
    bool CanFreeze
    {
        get;
    }
    bool IsFrozen
    {
        get;
    }

    void Freeze();
}

Pay attention to the CanFreeze property: I decided to use it because I wanted to test Freezables before freezing - and without giving the client a chance to do this, it is not good, in my opinion.

The Freezables concept is IMO a good idea that enriches the tool palette in multi-threaded applications.

+3
source

Freezable /, . WindowsBase.dll GDI32.DLL ( , ). , , , DispatcherObject Windows , , , Dispatcher. , DispatcherObject ( ESENT). , .

+1
source

Source: https://habr.com/ru/post/1726479/


All Articles