{"record":{"id":"00f2fb0ab0617ef1","repo":"EllanJiang/GameFramework","slug":"there-is-already-a-resource-pack-0-being-applied","errorCode":null,"errorMessage":"There is already a resource pack '{0}' being applied.","messagePattern":"There is already a resource pack '(.+?)' being applied\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceUpdater.cs","lineNumber":325,"sourceCode":"                {\n                    GenerateReadWriteVersionList();\n                }\n            }\n\n            /// <summary>\n            /// 应用指定资源包的资源。\n            /// </summary>\n            /// <param name=\"resourcePackPath\">要应用的资源包路径。</param>\n            public void ApplyResources(string resourcePackPath)\n            {\n                if (!m_CheckResourcesComplete)\n                {\n                    throw new GameFrameworkException(\"You must check resources complete first.\");\n                }\n\n                if (m_ApplyingResourcePackStream != null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"There is already a resource pack '{0}' being applied.\", m_ApplyingResourcePackPath));\n                }\n\n                if (m_UpdatingResourceGroup != null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"There is already a resource group '{0}' being updated.\", m_UpdatingResourceGroup.Name));\n                }\n\n                if (m_UpdateWaitingInfoWhilePlaying.Count > 0)\n                {\n                    throw new GameFrameworkException(\"There are already some resources being updated while playing.\");\n                }\n\n                try\n                {\n                    long length = 0L;\n                    ResourcePackVersionList versionList = default(ResourcePackVersionList);\n                    using (FileStream fileStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read))\n                    {","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceUpdater.cs#L307-L343","documentation":"ApplyResources throws this (with the pack path interpolated) when another resource pack is currently being applied — m_ApplyingResourcePackStream is non-null. Only one resource pack can be applied at a time because the manager holds an open FileStream for the pack being applied.","triggerScenarios":"Calling ApplyResources a second time while the first pack application is still in progress and its completion callback has not fired; re-entering ApplyResources from an event triggered during application.","commonSituations":"UI double-click or repeated retry logic firing ApplyResources twice; applying multiple packs in a loop without waiting for per-pack completion; an earlier application that stalled without a failure/success callback.","solutions":["Wait for the ResourceApplyStart/ResourceApplySuccess/ResourceApplyFailure callbacks before applying another pack","Queue pack paths and apply them sequentially from the completion callback","Guard the call with a UI/dispatch lock so duplicate invocations are ignored"],"exampleFix":"// before\nforeach (var pack in packs) resourceManager.ApplyResources(pack); // concurrent applies\n// after\nvoid OnApplyComplete(...) { if (queue.Count > 0) resourceManager.ApplyResources(queue.Dequeue()); }\nresourceManager.ApplyResources(queue.Dequeue());","handlingStrategy":"try-catch","validationCode":"// guard in caller code\nif (m_ApplyingPack) return; // already applying","typeGuard":null,"tryCatchPattern":"try { resourceManager.ApplyResources(packPath); } catch (GameFrameworkException ex) { Log.Warn(\"Pack application already in progress, queued: \" + ex.Message); m_PendingPacks.Enqueue(packPath); }","preventionTips":["Wait for ResourceApplySuccess/ResourceApplyFailure before applying another pack","Debounce UI triggers that start pack application","Maintain a sequential queue of packs in game code"],"tags":["csharp","gameframework","concurrency","invalid-state"],"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-16T04:17:20.429Z"}