Skip to content

Commit

Permalink
Merge pull request #389 from KirillBorunov/fix-show-same-dialog-after…
Browse files Browse the repository at this point in the history
…-await

Fix showing same dialog after awaiting dialog response
  • Loading branch information
ikkentim authored Nov 25, 2021
2 parents c88d53f + e22b79b commit d294bc0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/SampSharp.GameMode/Tools/ASyncWaiter`2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public virtual void Fire(TKey key, TArguments arguments)
if (key == null) throw new ArgumentNullException(nameof(key));
if (!_completionSources.ContainsKey(key)) return;

_completionSources[key].SetResult(arguments);
var task = _completionSources[key];
Remove(key);
task.SetResult(arguments);
}

/// <summary>
Expand All @@ -77,8 +78,9 @@ public virtual void Cancel(TKey key)
if (key == null) throw new ArgumentNullException(nameof(key));
if (!_completionSources.ContainsKey(key)) return;

_completionSources[key].TrySetCanceled();
var task = _completionSources[key];
Remove(key);
task.TrySetCanceled();
}

private void Remove(TKey key)
Expand All @@ -91,4 +93,4 @@ private void Remove(TKey key)
_completionSources.Remove(key);
}
}
}
}

0 comments on commit d294bc0

Please sign in to comment.