{"record":{"id":"baaab101cce6d7eb","repo":"EllanJiang/GameFramework","slug":"you-can-not-use-stopupdateresources-at-this-time","errorCode":null,"errorMessage":"You can not use StopUpdateResources at this time.","messagePattern":"You can not use StopUpdateResources at this time\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1346,"sourceCode":"\n        /// <summary>\n        /// 停止更新资源。\n        /// </summary>\n        public void StopUpdateResources()\n        {\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"You must set resource mode first.\");\n            }\n\n            if (m_ResourceMode != ResourceMode.Updatable && m_ResourceMode != ResourceMode.UpdatableWhilePlaying)\n            {\n                throw new GameFrameworkException(\"You can not use StopUpdateResources without updatable resource mode.\");\n            }\n\n            if (m_ResourceUpdater == null)\n            {\n                throw new GameFrameworkException(\"You can not use StopUpdateResources at this time.\");\n            }\n\n            m_ResourceUpdater.StopUpdateResources();\n            m_UpdateResourcesCompleteCallback = null;\n        }\n\n        /// <summary>\n        /// 校验资源包。\n        /// </summary>\n        /// <param name=\"resourcePackPath\">要校验的资源包路径。</param>\n        /// <returns>是否校验资源包成功。</returns>\n        public bool VerifyResourcePack(string resourcePackPath)\n        {\n            if (string.IsNullOrEmpty(resourcePackPath))\n            {\n                throw new GameFrameworkException(\"Resource pack path is invalid.\");\n            }\n","sourceCodeStart":1328,"sourceCodeEnd":1364,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1328-L1364","documentation":"StopUpdateResources() delegates to m_ResourceUpdater, which is created only while a resource update is actually in progress. If the updater instance is null, there is no ongoing update to stop, so ResourceManager throws this GameFrameworkException. It protects the internal invariant that a running updater exists before StopUpdateResources is forwarded to it.","triggerScenarios":"Calling StopUpdateResources() when no resource update is running (m_ResourceUpdater == null): e.g. calling it before UpdateResourceAsync, after the update already completed (updater released), or after the update failed and was cleaned up.","commonSituations":"Calling StopUpdateResources from a UI cancel button even when the update already finished; race between the UpdateResourcesComplete callback and a user-cancel action; calling stop twice.","solutions":["Track update state yourself and only call StopUpdateResources while UpdateResourceAsync is in flight (before the update-complete callback fires).","Listen for UpdateResourcesComplete/UpdateResourcesFailure events and mark the update as finished so stop is never called afterwards.","Catch the GameFrameworkException and treat it as 'no update running' if you cannot synchronize state."],"exampleFix":"// before\nresourceManager.StopUpdateResources(); // may throw if no update running\n// after\nif (m_IsUpdatingResources)\n{\n    resourceManager.StopUpdateResources();\n    m_IsUpdatingResources = false;\n}","handlingStrategy":"validation","validationCode":"if (!m_IsUpdatingResources) return; // only stop during a live update","typeGuard":null,"tryCatchPattern":"try { rm.StopUpdateResources(); } catch (GameFrameworkException) { /* update already finished; ignore */ }","preventionTips":["Set a bool flag on UpdateResourceAsync start and clear it in the complete/failure callbacks","Disable the cancel button once the update-complete event fires","Never call stop twice"],"tags":["gameframework","resource-update","invalid-state","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}