-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] 安装游戏完成后,偶发性按钮不变成开始游戏
等奇怪问题
#1083
Labels
Comments
1 task
iamscottxu
added a commit
to iamscottxu/Starward
that referenced
this issue
Sep 8, 2024
… times by multiple threads (Scighost#1083) (Scighost#1082) Signed-off-by: OsakaRuma <[email protected]>
很可惜,修改后的代码没能通过测试,一键修复过程完成校验后,无法进入到下载流程。 |
抱歉,无法进入下载流程的原因是没有考虑到 |
Scighost
pushed a commit
that referenced
this issue
Sep 15, 2024
…tiple times by multiple threads (#1084) * fixed the bug that method `CurrentTaskFinished` was executed multiple times by multiple threads (#1083) (#1082) Signed-off-by: OsakaRuma <[email protected]> * handling exception, deleted voice code Signed-off-by: OsakaRuma <[email protected]> * fixed typo of variable name Signed-off-by: OsakaRuma <[email protected]> * fixed typo in variable name Signed-off-by: OsakaRuma <[email protected]> * fixed a bug where only the first step of the task could be run if there were multiple steps of the task when installing the game Signed-off-by: OsakaRuma <[email protected]> --------- Signed-off-by: OsakaRuma <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checklist
Description
InstallGameService.cs:
除#1082,可能会造成此问题外,
protected void StartTask(InstallGameState state)
方法中ExecuteTaskItemAsync
调用时不等待,而直接返回,且protected async Task ExecuteTaskItemAsync(CancellationToken cancellationToken = default)
方法中在finally中使用判断_concurrentExecuteThreadCount
是否等于0的机制也会造成本该执行一次的private void CurrentTaskFinished()
方法被反复执行。而CurrentTaskFinished
方法的代码逻辑线程不安全,造成”安装游戏完成后,偶发性按钮不变成开始游戏
等奇怪问题“。会反复执行的原因在于,C#中的异步方法如果不进行特殊处理,调用后就会被立即执行,即在
StartTask
中循环还没有执行完成,前面启动的ExecuteTaskItemAsync
异步任务已经在执行当中了,这会导致当任务执行速度较快时,启动异步任务的循环还没有结束,这样线程计数器_concurrentExecuteThreadCount
会多次等于0,造成CurrentTaskFinished
方法被反复执行。解决方法是,使用
Task.WhenAll
方法等待所有任务执行完成后,再调用CurrentTaskFinished
方法。Reproduction Steps
将
protected async Task ExecuteTaskItemAsync(CancellationToken cancellationToken = default)
中的带有await
调用的代码清空,让其快速执行完成,即可相对稳定地复现此问题。Expected Behavior
No response
Screenshots
No response
Starward Version
main分支:37253b8
Windows Version
与操作系统版本无关
Log
No response
Additional Context
已经提pr #1084 修复。
The text was updated successfully, but these errors were encountered: