-
Notifications
You must be signed in to change notification settings - Fork 479
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
fix for multi user scenario #3118
Conversation
264bcf0
to
b68c523
Compare
Looks good to me, Random.Next is not thread-safe. Request Tom and ChrisMc to review and confirm. @xieofxie do you have a scenario that multi-thread is used, maybe we can check in with some tests if it's a typical use case? |
@boydc2014 Unfortunately, after some searching, I didn't find examples about how to write tests for concurrency. I write one myself here xieofxie@79c86cc, but it looks not good enough for me. Typically this happens when bot is used by multiple users and they happen to run into same functions. |
libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/RandomSelector.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not thread-safe when multiple users call these functions.
Also we must use
services.AddSingleton<IBot, TestBot>()
for the state of RandomSelector._rand