Exemplo n.º 1
0
        public O CallFunc <I, O>(Func <I, O> func, I inData)
        {
            var helper = new CallHelperSafeHelper <I, O>()
            {
                inData = inData, toCall = func
            };

            CallAction(helper.AsAction);
            return(helper.outData);
        }
Exemplo n.º 2
0
        public T CallFunc <T>(Func <T> func)
        {
            var toFunc = new FuncConv <T>()
            {
                toCall = func
            };
            var helper = new CallHelperSafeHelper <bool, T>()
            {
                inData = true, toCall = new Func <bool, T>(toFunc.Call)
            };

            CallAction(helper.AsAction);
            return(helper.outData);
        }
Exemplo n.º 3
0
        public static O DefaultCallFunc <I, O>(Func <I, O> f, I d)
        {
            var helper = new CallHelperSafeHelper <I, O>()
            {
                inData = d, toCall = f
            };

            ExecutionContext.Run(EmptyExecutionContext.Empty, helper.AsContextCallback, null);
            return(helper.outData);
            //using (var t = Create())
            //{
            //    return t.CallFunc(f, d);
            //}
            //return Default.CallFunc(f, d);
        }
Exemplo n.º 4
0
        //private static readonly Lazy<ExecutionContextLessThread> defaultThread = new Lazy<ExecutionContextLessThread>(Create);
        //public static ExecutionContextLessThread Default
        //{
        //    get
        //    {
        //        return defaultThread.Value;
        //    }
        //}
        public static void DefaultCallAction(Action a)
        {
            var toFunc = new ActionConv()
            {
                toCall = a
            };
            var helper = new CallHelperSafeHelper <bool, bool>()
            {
                inData = true, toCall = new Func <bool, bool>(toFunc.Call)
            };

            ExecutionContext.Run(EmptyExecutionContext.Empty, helper.AsContextCallback, null);
            //using (var t = Create())
            //{
            //    t.CallAction(a);
            //}
            //Default.CallAction(a);
        }
Exemplo n.º 5
0
        public static O DefaultCallFunc <O>(Func <O> f)
        {
            var toFunc = new FuncConv <O>()
            {
                toCall = f
            };
            var helper = new CallHelperSafeHelper <bool, O>()
            {
                inData = true, toCall = new Func <bool, O>(toFunc.Call)
            };

            ExecutionContext.Run(EmptyExecutionContext.Empty, helper.AsContextCallback, null);
            return(helper.outData);
            //using (var t = Create())
            //{
            //    return t.CallFunc(f);
            //}
            //return Default.CallFunc(f);
        }