Skip to content
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

[Question]Lesson 3.3: Use of .Result #275

Open
NickPolyder opened this issue Aug 19, 2018 · 0 comments
Open

[Question]Lesson 3.3: Use of .Result #275

NickPolyder opened this issue Aug 19, 2018 · 0 comments

Comments

@NickPolyder
Copy link

Hello,
Although i completely accept the concept of blocking code to get the results needed.
Is there any particular reason that you are using

// GithubCommanderActor's BecomeAsking method - replace it with this
private void BecomeAsking()
{
    _canAcceptJobSender = Sender;
    // block, but ask the router for the number of routees. Avoids magic numbers.
    pendingJobReplies = _coordinator.Ask<Routees>(new GetRoutees())
      .Result.Members.Count(); // Usage of .Result
    Become(Asking);
}

Instead of using .GetAwaiter().GetResult() which is the preferred way to avoid possible deadlocks and miss behaviors ?

// GithubCommanderActor's BecomeAsking method - replace it with this
private void BecomeAsking()
{
    _canAcceptJobSender = Sender;
    // block, but ask the router for the number of routees. Avoids magic numbers.
    pendingJobReplies = _coordinator.Ask<Routees>(new GetRoutees())
                                    .GetAwaiter()
                                    .GetResult()
                                    .Members.Count(); 
    Become(Asking);
}

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant