Changed Listener.Block to not use as much CPU usage, at least not visually in the task manager.
This commit is contained in:
parent
f882a74c6d
commit
662bd03ddc
@ -70,14 +70,6 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
|
||||
Console.WriteLine($"Rest api server running at {listener.BaseUrl}");
|
||||
|
||||
var client = new Client(listener.BaseUrl);
|
||||
|
||||
var result = client.Auth.Get();
|
||||
|
||||
StaticClient.Init(listener.BaseUrl);
|
||||
|
||||
var result2 = StaticClient.Auth.Get();
|
||||
|
||||
listener.Block();
|
||||
}
|
||||
|
||||
|
@ -215,9 +215,12 @@ namespace MontoyaTech.Rest.Net
|
||||
/// </summary>
|
||||
public void Block()
|
||||
{
|
||||
while (this.HttpListener != null && Thread.CurrentThread.ThreadState != ThreadState.AbortRequested && Thread.CurrentThread.ThreadState != ThreadState.Aborted)
|
||||
if (!Thread.Yield())
|
||||
Thread.Sleep(1000);
|
||||
try
|
||||
{
|
||||
while (this.HttpListener != null && this.HttpListener.IsListening && Thread.CurrentThread.ThreadState != ThreadState.AbortRequested && Thread.CurrentThread.ThreadState != ThreadState.Aborted)
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user