Example #1
0
    void IInvocation.invoke()
    {
        if (avalabilityCheck() == false)
        {
            return;
        }

        if (_hasReturnValue)
        {
            R obj = default(R);
            switch (_argCount)
            {
            case 0:
                Func <R> f = (Func <R>)_func;
                obj = f();
                break;

            case 1:
                Func1 <R, Arg1> f1 = (Func1 <R, Arg1>)_func;
                obj = f1((Arg1)_argList[0]);
                break;

            case 2:
                Func2 <R, Arg1, Arg2> f2 = (Func2 <R, Arg1, Arg2>)_func;
                obj = f2((Arg1)_argList[0], (Arg2)_argList[1]);
                break;

            default:
                Log.infoError("Function with " + _argCount + " arguments is not supported!");
                break;
            }

            _returnValue = (object)obj;
        }
        else
        {
            switch (_argCount)
            {
            case 0:
                VFunc vf = (VFunc)_func;
                vf();
                break;

            case 1:
                VFunc1 <Arg1> vf1 = (VFunc1 <Arg1>)_func;
                vf1((Arg1)_argList[0]);
                break;

            case 2:
                VFunc2 <Arg1, Arg2> vf2 = (VFunc2 <Arg1, Arg2>)_func;
                vf2((Arg1)_argList[0], (Arg2)_argList[1]);
                break;

            default:
                Log.infoError("Function with " + _argCount + " arguments is not supported!");
                break;
            }
        }
    }
Example #2
0
    static public Operation DoVoidFuncOnThread(LoopThread loopThrad, VFunc func, VFunc callback = null, bool callbackOnMainThread = true, long delay = 0)
    {
        Invocation <Null, Null, Null> inv   = new Invocation <Null, Null, Null> (func);
        Invocation <Null, Null, Null> cbInv = callback == null ? null : new Invocation <Null, Null, Null> (callback);
        Operation operation = new Operation(inv, ApplicationEX.GetCurrnSystemMillisecond() + delay, cbInv, callbackOnMainThread);

        loopThrad.addExecution(operation);
        return(operation);
    }
Example #3
0
    static public Operation DoVoidFuncOnMainThread(VFunc func, long delay = 0, VFunc cb = null)
    {
        Invocation <Null, Null, Null> invocation = new Invocation <Null, Null, Null> (func, 0, null);
        Invocation <Null, Null, Null> cbInvo     = cb == null ? null : new Invocation <Null, Null, Null> (cb, 0, null);
        Operation operation = new Operation(invocation, ApplicationEX.GetCurrnSystemMillisecond() + delay, cbInvo);

        //MainThread.Instance.addExcutable (operation);
        DoOperation(operation);
        return(operation);
    }
Example #4
0
    static public Operation DoVoidFuncOnMainThread <Arg1, Arg2>(VFunc2 <Arg1, Arg2> func, Arg1 arg1, Arg2 arg2, long delay = 0, VFunc cb = null)
    {
        object[] argList = { arg1, arg2 };
        Invocation <Null, Arg1, Arg2> invocation = new Invocation <Null, Arg1, Arg2> (func, 2, argList);
        Invocation <Null, Null, Null> cbInvo     = cb == null ? null : new Invocation <Null, Null, Null> (cb, 0, null);
        Operation operation = new Operation(invocation, ApplicationEX.GetCurrnSystemMillisecond() + delay, cbInvo);

        MainThread.Instance.addExcutable(operation);
        return(operation);
    }
Example #5
0
    static public Operation DoVoidFuncOnThread <Arg1, Arg2>(LoopThread loopThrad, VFunc2 <Arg1, Arg2> func, Arg1 arg1, Arg2 arg2, VFunc callback = null, bool callbackOnMainThread = true, long delay = 0)
    {
        object[] args = { arg1, arg2 };
        Invocation <Null, Arg1, Arg2> inv   = new Invocation <Null, Arg1, Arg2> (func, 2, args);
        Invocation <Null, Null, Null> cbInv = callback == null ? null : new Invocation <Null, Null, Null> (callback);
        Operation operation = new Operation(inv, ApplicationEX.GetCurrnSystemMillisecond() + delay, cbInv, callbackOnMainThread);

        loopThrad.addExecution(operation);
        return(operation);
    }
Example #6
0
 static public Operation DoVoidFuncInBackground <Arg1, Arg2>(VFunc2 <Arg1, Arg2> func, Arg1 arg1, Arg2 arg2, VFunc callback = null, bool callbackOnMainThread = true, long delay = 0)
 {
     return(DoVoidFuncOnThread <Arg1, Arg2> (ApplicationEX.BackgroundThread, func, arg1, arg2, callback, callbackOnMainThread, delay));
 }
Example #7
0
    //*************************************************后台操作分割线********************************************************//


    static public Operation DoVoidFuncInBackground(VFunc func, VFunc cb = null, bool callbackOnMainThread = true, long delay = 0)
    {
        return(DoVoidFuncOnThread(ApplicationEX.BackgroundThread, func, cb, callbackOnMainThread, delay));
    }
Example #8
0
 static VAction <T, Entity> StructGet <T, TField>(string name, VFunc <T, TField> getter) =>
 (ref T obj, Entity e) => e[name] = Value <TField> .To(getter(ref obj));