Пример #1
0
        public static LifetimeDef DefineDependent(OuterLifetime parent, string name = null)
        {
            var def = Define(name);

            void TerminateDefinition() => def.Terminate();

            parent.Lifetime.Add(TerminateDefinition);
            def.Lifetime.Add(() => parent.Lifetime.Remove(TerminateDefinition));

            return(def);
        }
Пример #2
0
 public static EventHandler <T> Create(OuterLifetime outer, TaskScheduler context = null)
 {
     return(new EventHandler <T>(outer, context ?? TaskScheduler.Current));
 }
Пример #3
0
 protected EventHandler(OuterLifetime outer, TaskScheduler scheduler)
 {
     _scheduler = scheduler;
     _lfd       = Lifetime.DefineDependent(outer, typeof(EventHandler <T>).FullName);
 }