Exemple #1
0
        public ResetLazy <T> GlobalLazy <T>(Func <T> func, InvalidateWith invalidateWith) where T : class
        {
            var result = Signum.Engine.GlobalLazy.WithoutInvalidations(() =>
            {
                GlobalLazyManager.OnLoad(this, invalidateWith);

                return(func());
            });

            GlobalLazyManager.AttachInvalidations(this, invalidateWith, (sender, args) => result.Reset());

            return(result);
        }
Exemple #2
0
        public ResetLazy <T> GlobalLazy <T>(Func <T> func, InvalidateWith invalidateWith, Action onInvalidated = null, LazyThreadSafetyMode mode = LazyThreadSafetyMode.ExecutionAndPublication) where T : class
        {
            var result = Signum.Engine.GlobalLazy.WithoutInvalidations(() =>
            {
                GlobalLazyManager.OnLoad(this, invalidateWith);

                return(func());
            });

            GlobalLazyManager.AttachInvalidations(this, invalidateWith, (sender, args) =>
            {
                result.Reset();
                onInvalidated?.Invoke();
            });

            return(result);
        }