From de5951f208fabd1f2e45a98e006648f42ed61936 Mon Sep 17 00:00:00 2001 From: neuecc Date: Fri, 12 Jun 2020 10:46:29 +0900 Subject: [PATCH] lock q --- .../Runtime/Linq/ToUniTaskAsyncEnumerable.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/ToUniTaskAsyncEnumerable.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/ToUniTaskAsyncEnumerable.cs index 7867a8b..02523c6 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/ToUniTaskAsyncEnumerable.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/ToUniTaskAsyncEnumerable.cs @@ -248,15 +248,18 @@ namespace Cysharp.Threading.Tasks.Linq return current; } - if (queuedResult.Count != 0) + lock (queuedResult) { - current = queuedResult.Dequeue(); - useCachedCurrent = true; - return current; - } - else - { - return default; // undefined. + if (queuedResult.Count != 0) + { + current = queuedResult.Dequeue(); + useCachedCurrent = true; + return current; + } + else + { + return default; // undefined. + } } } }