Example #1
0
        public bool Resume(out object retVal)
        {
            if (this.thread == IntPtr.Zero)
            {
                Logger.LogError("thread: already disposed?");
                retVal = null;
                return(false);
            }

            int status = LuaNativeMethods.lua_status(this.thread);

            if (status != 0 && status != (int)LuaThreadStatus.LUA_YIELD)
            {
                Logger.LogError("thread: wrong status ?= " + status);
                retVal = null;
                return(false);
            }

            int result = LuaNativeMethods.lua_resume(this.thread, 0);

            if (result != (int)LuaThreadStatus.LUA_YIELD)
            {
                if (result != 0)
                {
                    string error = LuaNativeMethods.lua_tostring(this.thread, -1);
                    Logger.LogError(string.Format("wrong result ?= {0} err: {1}", result, error));
                }

                retVal = null;
                return(false);
            }

            int argsFromYield = LuaNativeMethods.lua_gettop(this.thread);

            retVal = this.TopObjects(argsFromYield);
            return(true);
        }