{"record":{"id":"169106d776d63b4c","repo":"egametang/ET","slug":"ettask-does-not-allow-call-getresult-directly-when","errorCode":null,"errorMessage":"ETTask does not allow call GetResult directly when task not completed. Please use 'await'.","messagePattern":"ETTask 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":203,"sourceCode":"            this.UnsafeOnCompleted(action);\n        }\n\n        [DebuggerHidden]\n        public void GetResult()\n        {\n            switch (this.state)\n            {\n                case AwaiterStatus.Succeeded:\n                    this.Recycle();\n                    break;\n                case AwaiterStatus.Faulted:\n                    ExceptionDispatchInfo c = this.callback as ExceptionDispatchInfo;\n                    this.callback = null;\n                    this.Recycle();\n                    c?.Throw();\n                    break;\n                default:\n                    throw new NotSupportedException(\"ETTask does not allow call GetResult directly when task not completed. Please use 'await'.\");\n            }\n        }\n\n        [DebuggerHidden]\n        public void SetResult()\n        {\n            if (this.state != AwaiterStatus.Pending)\n            {\n                throw new InvalidOperationException(\"TaskT_TransitionToFinal_AlreadyCompleted\");\n            }\n\n            this.state = AwaiterStatus.Succeeded;\n\n            Action c = this.callback as Action;\n            this.callback = null;\n            c?.Invoke();\n        }\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/ETTask/ETTask.cs#L185-L221","documentation":"Thrown by ETTask.GetResult() when the task's state is neither Succeeded nor Faulted — i.e. still Pending. The ET coroutine framework requires callers to await completion before reading the result; reading it early is undefined and explicitly rejected with NotSupportedException. This usually indicates calling GetResult manually instead of awaiting.","triggerScenarios":"Invoking task.GetResult() before the coroutine has finished; manually driving an ETTask without awaiting; polling a task in a busy loop and reading result too early; awaiter misuse that skips awaiting.","commonSituations":"Replacing await with a manual GetAwaiter().GetResult() call on an incomplete task; synchronous-looking code over async ET coroutines; debugging code that probes result eagerly; forgetting that ETTask completion is fiber-driven.","solutions":["Always await the ETTask: await task; before inspecting its result.","If you must poll, check the task's completion state (IsCompleted) before GetResult.","Refactor manual GetResult call sites into proper async/await."],"exampleFix":"// before\ntask.GetResult(); // throws if not completed\n\n// after\nawait task; // safe: blocks coroutine until completion","handlingStrategy":"validation","validationCode":"// Only read result after completion.\nif (!task.IsCompleted) await task;\ntask.GetResult(); // now safe","typeGuard":null,"tryCatchPattern":"try { task.GetResult(); } catch (NotSupportedException ex) when (ex.Message.Contains(\"not completed\")) { await task; }","preventionTips":["Always await ETTask instead of calling GetResult manually.","Check IsCompleted before any manual result probe.","Refactor synchronous-looking GetResult call sites into async/await."],"tags":["ettask","async","coroutine","misuse","csharp","unity"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}