Skip to content

Commit

Permalink
[core] Remove some more .Result calls
Browse files Browse the repository at this point in the history
These ones were right after an 'await' so they are guaranteed to
succeed every time, but for code hygiene it is better to do it
without the .Result call.
  • Loading branch information
alanmcgovern committed Aug 20, 2019
1 parent 07b32c2 commit b5fabb6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MonoTorrent/MonoTorrent.Client.Tracker/UdpTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ protected override async Task<List<Peer>> DoAnnounceAsync (AnnounceParameters pa
try {
if (ConnectionIdTask == null || LastConnected.Elapsed > TimeSpan.FromMinutes (1))
ConnectionIdTask = ConnectAsync ();
await ConnectionIdTask;
var connectionId = await ConnectionIdTask;

var message = new AnnounceMessage (DateTime.Now.GetHashCode (), ConnectionIdTask.Result, parameters);
var message = new AnnounceMessage (DateTime.Now.GetHashCode (), connectionId, parameters);
var announce = (AnnounceResponseMessage) await SendAndReceiveAsync (message);
MinUpdateInterval = announce.Interval;

Expand All @@ -74,10 +74,10 @@ protected override async Task DoScrapeAsync (ScrapeParameters parameters)
try {
if (ConnectionIdTask == null || LastConnected.Elapsed > TimeSpan.FromMinutes (1))
ConnectionIdTask = ConnectAsync ();
await ConnectionIdTask;
var connectionId = await ConnectionIdTask;

var infohashes = new List<byte[]> { parameters.InfoHash.Hash };
var message = new ScrapeMessage (DateTime.Now.GetHashCode (), ConnectionIdTask.Result, infohashes);
var message = new ScrapeMessage (DateTime.Now.GetHashCode (), connectionId, infohashes);
var response = (ScrapeResponseMessage) await SendAndReceiveAsync (message);

if (response.Scrapes.Count == 1) {
Expand Down

0 comments on commit b5fabb6

Please sign in to comment.