Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 61607f0

Browse files
author
Matt Collins
committed
bitbucket: Remove calls to Thread.Sleep
1 parent ed7e810 commit 61607f0

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Bitbucket.Authentication/Src/OAuth/SimpleServer.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,12 @@ public static async Task<string> WaitForURLAsync(string url, CancellationToken c
5656
var context = await listener.GetContextAsync().RunWithCancellation(cancellationToken);
5757
rawUrl = context.Request.RawUrl;
5858

59-
Thread.Sleep(100); // Wait 100ms without this the server closes before the complete response has been written
60-
6159
// Serve back a simple authentication message.
6260
var html = GetSuccessString();
6361
var buffer = System.Text.Encoding.UTF8.GetBytes(html);
6462
context.Response.ContentLength64 = buffer.Length;
65-
Task responseTask = context.Response.OutputStream.WriteAsync(buffer, 0, buffer.Length).ContinueWith((task) =>
66-
{
67-
context.Response.OutputStream.Close();
68-
listener.Stop();
69-
});
70-
71-
Thread.Sleep(100);
63+
await context.Response.OutputStream.WriteAsync(buffer, 0, buffer.Length, cancellationToken);
64+
context.Response.Close();
7265
}
7366
catch (TimeoutException ex)
7467
{

0 commit comments

Comments
 (0)