Commit 1edcb327 authored by justcoding121's avatar justcoding121

cleanup

parent 20ef5aec
...@@ -17,15 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -17,15 +17,16 @@ namespace Titanium.Web.Proxy.Examples.Basic
{ {
public class ProxyTestController : IDisposable public class ProxyTestController : IDisposable
{ {
private readonly SemaphoreSlim @lock = new SemaphoreSlim(1);
private readonly ProxyServer proxyServer; private readonly ProxyServer proxyServer;
private ExplicitProxyEndPoint explicitEndPoint; private ExplicitProxyEndPoint explicitEndPoint;
private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private CancellationToken cancellationToken => cancellationTokenSource.Token; private CancellationToken cancellationToken => cancellationTokenSource.Token;
private ConcurrentQueue<Tuple<ConsoleColor?, string>> consoleMessageQueue; private ConcurrentQueue<Tuple<ConsoleColor?, string>> consoleMessageQueue
= new ConcurrentQueue<Tuple<ConsoleColor?, string>>();
public ProxyTestController() public ProxyTestController()
{ {
consoleMessageQueue = new ConcurrentQueue<Tuple<ConsoleColor?, string>>();
Task.Run(()=> listenToConsole()); Task.Run(()=> listenToConsole());
proxyServer = new ProxyServer(); proxyServer = new ProxyServer();
...@@ -415,7 +416,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -415,7 +416,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
{ {
while (!cancellationToken.IsCancellationRequested) while (!cancellationToken.IsCancellationRequested)
{ {
if (consoleMessageQueue.TryDequeue(out var item)) while (consoleMessageQueue.TryDequeue(out var item))
{ {
var consoleColor = item.Item1; var consoleColor = item.Item1;
var message = item.Item2; var message = item.Item2;
...@@ -434,7 +435,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -434,7 +435,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
} }
//reduce CPU usage //reduce CPU usage
await Task.Delay(10); await Task.Delay(50);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment