{"record":{"id":"2827790c02f1adc8","repo":"egametang/ET","slug":"etask-does-not-allow-call-getresult-directly-when","errorCode":null,"errorMessage":"ETask does not allow call GetResult directly when task not completed. Please use 'await'.","messagePattern":"ETask does not allow call GetResult directly when task not completed\\. Please use 'await'\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/ETTask/ETTask.cs","lineNumber":351,"sourceCode":"        }\n\n        [DebuggerHidden]\n        public T GetResult()\n        {\n            switch (this.state)\n            {\n                case AwaiterStatus.Succeeded:\n                    T v = this.value;\n                    this.Recycle();\n                    return v;\n                case AwaiterStatus.Faulted:\n                    ExceptionDispatchInfo c = this.callback as ExceptionDispatchInfo;\n                    this.callback = null;\n                    this.Recycle();\n                    c?.Throw();\n                    return default;\n                default:\n                    throw new NotSupportedException(\"ETask does not allow call GetResult directly when task not completed. Please use 'await'.\");\n            }\n        }\n        \n        public bool IsCompleted\n        {\n            [DebuggerHidden]\n            get\n            {\n                return state != AwaiterStatus.Pending;\n            }\n        } \n\n        [DebuggerHidden]\n        public void UnsafeOnCompleted(Action action)\n        {\n            if (this.state != AwaiterStatus.Pending)\n            {\n                action?.Invoke();","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/ETTask/ETTask.cs#L333-L369","documentation":"Thrown by ETTask<T>.GetResult when state is neither Succeeded nor Faulted (i.e. still Pending). GetResult is the awaiter's result accessor; the ET contract forbids calling it before the task has completed. Use `await` (which the compiler turns into a state machine that only calls GetResult after IsCompleted), never call GetResult directly.","triggerScenarios":"Calling `task.GetAwaiter().GetResult()` (or task.GetResult()) synchronously on an unfinished ETTask; awaiting a task whose completion was never triggered; .Result/.Wait()-style blocking access on ET tasks.","commonSituations":"Porting code that used Task<T>.Result / .GetAwaiter().GetResult() blocking reads to ET tasks; forgetting to start the producer that completes the task; calling GetResult from a non-async context instead of awaiting.","solutions":["Replace direct GetResult() with `await task` so the compiler only calls GetResult after completion.","If you must block, ensure the task is completed first (check IsCompleted), or restructure to push the work into an async method.","Verify the producer code path that should SetResult/SetException this task is actually reached."],"exampleFix":"// before\nT value = task.GetAwaiter().GetResult();\n\n// after\nT value = await task;","handlingStrategy":"validation","validationCode":"// never call GetResult before completion\nif (task.IsCompleted)\n{\n    var v = task.GetAwaiter().GetResult();\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    T v = await task;   // preferred: compiler gates GetResult\n}\ncatch (NotSupportedException)\n{\n    Log.Error(\"task not completed before GetResult\");\n}","preventionTips":["Prefer `await task` over manual GetResult.","Never block on unfinished ET tasks with .Result/.GetAwaiter().GetResult().","Confirm the producer reaches a terminal state."],"tags":["ettask","async","getresult","core"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}