diff --git a/BandWidthMonitor/App.config b/BandWidthMonitor/App.config
deleted file mode 100644
index 8e15646..0000000
--- a/BandWidthMonitor/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/BandWidthMonitor/BandwidthLogger.cs b/BandWidthMonitor/BandwidthLogger.cs
index d6ddf95..8e0db24 100644
--- a/BandWidthMonitor/BandwidthLogger.cs
+++ b/BandWidthMonitor/BandwidthLogger.cs
@@ -15,8 +15,8 @@ class BandwidthLogger : IDisposable
public BandwidthLogger(TimeSpan logFrequency)
{
if (logFrequency <= TimeSpan.Zero)
- {
- throw new ArgumentOutOfRangeException("logFrequency");
+ {
+ throw new ArgumentOutOfRangeException("logFrequency");
}
_logFrequency = logFrequency;
@@ -31,7 +31,7 @@ private async void StartLogging()
{
const long bitsPerByte = 8;
const double oneMeg = 1024 * 1024;
-
+
while (!_disposed)
{
@@ -40,13 +40,13 @@ private async void StartLogging()
long bytesRead;
long bytesWrite;
GetNetworkUsage(out bytesRead, out bytesWrite);
-
+
DateTimeOffset currentTime = DateTimeOffset.UtcNow;
TimeSpan elapsed = currentTime - _previousComputeTime;
-
+
long readDelta = (bytesRead - _previousReadBytes);
long writeDelta = (bytesWrite - _previousWriteBytes);
-
+
_previousReadBytes = bytesRead;
_previousWriteBytes = bytesWrite;
_previousComputeTime = currentTime;
@@ -57,7 +57,7 @@ private async void StartLogging()
LogUsage(mbitsReadPerSecond, mbitsWritePerSecond);
}
}
- catch(Exception)
+ catch (Exception)
{
}
@@ -88,7 +88,7 @@ private static void GetNetworkUsage(out long bytesRead, out long bytesWrite)
bytesWrite += nicbytesWrite;
}
}
- catch(Exception)
+ catch (Exception)
{
}
diff --git a/BandWidthMonitor/BandwidthMonitor.csproj b/BandWidthMonitor/BandwidthMonitor.csproj
index bb259b8..e07696a 100644
--- a/BandWidthMonitor/BandwidthMonitor.csproj
+++ b/BandWidthMonitor/BandwidthMonitor.csproj
@@ -1,59 +1,21 @@
-
-
-
-
- Debug
- AnyCPU
- {704D6A6C-711C-4332-9248-5F7009C1E071}
- Exe
- Properties
- BandwidthMonitor
- BandwidthMonitor
- v4.5
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+ Exe
+ netcoreapp3.1
+ true
+ true
+
+ win10-x64
+
+
+
+
+
+
+ false
+
+
+
diff --git a/BandWidthMonitor/Program.cs b/BandWidthMonitor/Program.cs
index c79d5c3..8dd4cc2 100644
--- a/BandWidthMonitor/Program.cs
+++ b/BandWidthMonitor/Program.cs
@@ -1,6 +1,7 @@
-using System;
+using BandwidthMonitor;
+using System;
-namespace BandwidthMonitor
+namespace BandWidthMonitor
{
class Program
{
@@ -11,6 +12,6 @@ static void Main(string[] args)
Console.WriteLine("Press Enter to close application");
Console.ReadLine();
}
- }
+ }
}
}
diff --git a/BandWidthMonitor/Properties/AssemblyInfo.cs b/BandWidthMonitor/Properties/AssemblyInfo.cs
index 02e7e4e..466e1d6 100644
--- a/BandWidthMonitor/Properties/AssemblyInfo.cs
+++ b/BandWidthMonitor/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/ThreadPoolMonitor/App.config b/ThreadPoolMonitor/App.config
deleted file mode 100644
index 8e15646..0000000
--- a/ThreadPoolMonitor/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ThreadPoolMonitor/PerfCounterHelper.cs b/ThreadPoolMonitor/PerfCounterHelper.cs
index 9761902..43b1870 100644
--- a/ThreadPoolMonitor/PerfCounterHelper.cs
+++ b/ThreadPoolMonitor/PerfCounterHelper.cs
@@ -1,7 +1,5 @@
using System;
using System.Diagnostics;
-using System.Threading;
-using System.Threading.Tasks;
namespace ThreadPoolMonitor
{
@@ -18,7 +16,7 @@ public static string GetSystemCPU()
float systemCPU;
if (PerfCounterHelper.TryGetSystemCPU(out systemCPU))
{
- cpu = Math.Round(systemCPU, 2) + "%";
+ cpu = Math.Round(systemCPU, 2) + "%";
}
return cpu;
}
diff --git a/ThreadPoolMonitor/Program.cs b/ThreadPoolMonitor/Program.cs
index f10a832..e68fd41 100644
--- a/ThreadPoolMonitor/Program.cs
+++ b/ThreadPoolMonitor/Program.cs
@@ -13,6 +13,6 @@ static void Main(string[] args)
Console.WriteLine("Press Enter to close application");
Console.ReadLine();
}
- }
+ }
}
}
diff --git a/ThreadPoolMonitor/Properties/AssemblyInfo.cs b/ThreadPoolMonitor/Properties/AssemblyInfo.cs
index 00cd149..f5465d3 100644
--- a/ThreadPoolMonitor/Properties/AssemblyInfo.cs
+++ b/ThreadPoolMonitor/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/ThreadPoolMonitor/ThreadPoolLogger.cs b/ThreadPoolMonitor/ThreadPoolLogger.cs
index 32f06d5..b5be9bf 100644
--- a/ThreadPoolMonitor/ThreadPoolLogger.cs
+++ b/ThreadPoolMonitor/ThreadPoolLogger.cs
@@ -4,102 +4,102 @@
namespace ThreadPoolMonitor
{
- class ThreadPoolLogger : IDisposable
- {
- private TimeSpan _logFrequency;
- private bool _disposed;
-
- public ThreadPoolLogger(TimeSpan logFrequency)
- {
- if (logFrequency <= TimeSpan.Zero)
- {
- throw new ArgumentOutOfRangeException("logFrequency");
- }
-
- _logFrequency = logFrequency;
- StartLogging();
- }
-
- private async void StartLogging()
- {
- try
- {
- while (!_disposed)
- {
- await Task.Delay(_logFrequency);
-
- var stats = GetThreadPoolStats();
-
- LogUsage(stats);
- }
- }
- catch(Exception)
- {
-
- }
- }
-
- protected virtual void LogUsage(ThreadPoolUsageStats stats)
- {
- string message = string.Format("[{0}] IOCP:(Busy={1},Min={2},Max={3}), WORKER:(Busy={4},Min={5},Max={6}), Local CPU: {7}",
- DateTimeOffset.UtcNow.ToString("u"),
- stats.BusyIoThreads, stats.MinIoThreads, stats.MaxIoThreads,
- stats.BusyWorkerThreads, stats.MinWorkerThreads, stats.MaxWorkerThreads,
- PerfCounterHelper.GetSystemCPU()
- );
-
- Console.WriteLine(message);
- }
-
- ///
- /// Returns the current thread pool usage statistics for the CURRENT AppDomain/Process
- ///
- public static ThreadPoolUsageStats GetThreadPoolStats()
- {
- //BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
- //If BusyThreads >= TP.GetMinThreads(), then threadpool growth throttling is possible.
-
- int maxIoThreads, maxWorkerThreads;
- ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxIoThreads);
-
- int freeIoThreads, freeWorkerThreads;
- ThreadPool.GetAvailableThreads(out freeWorkerThreads, out freeIoThreads);
-
- int minIoThreads, minWorkerThreads;
- ThreadPool.GetMinThreads(out minWorkerThreads, out minIoThreads);
-
- int busyIoThreads = maxIoThreads - freeIoThreads;
- int busyWorkerThreads = maxWorkerThreads - freeWorkerThreads;
-
- return new ThreadPoolUsageStats
- {
- BusyIoThreads = busyIoThreads,
- MinIoThreads = minIoThreads,
- MaxIoThreads = maxIoThreads,
- BusyWorkerThreads = busyWorkerThreads,
- MinWorkerThreads = minWorkerThreads,
- MaxWorkerThreads = maxWorkerThreads,
- };
- }
-
- public void Dispose()
- {
- _disposed = true;
- }
- }
-
- public struct ThreadPoolUsageStats
- {
- public int BusyIoThreads { get; set; }
-
- public int MinIoThreads { get; set; }
-
- public int MaxIoThreads { get; set; }
-
- public int BusyWorkerThreads { get; set; }
-
- public int MinWorkerThreads { get; set; }
-
- public int MaxWorkerThreads { get; set; }
- }
+ class ThreadPoolLogger : IDisposable
+ {
+ private TimeSpan _logFrequency;
+ private bool _disposed;
+
+ public ThreadPoolLogger(TimeSpan logFrequency)
+ {
+ if (logFrequency <= TimeSpan.Zero)
+ {
+ throw new ArgumentOutOfRangeException("logFrequency");
+ }
+
+ _logFrequency = logFrequency;
+ StartLogging();
+ }
+
+ private async void StartLogging()
+ {
+ try
+ {
+ while (!_disposed)
+ {
+ await Task.Delay(_logFrequency);
+
+ var stats = GetThreadPoolStats();
+
+ LogUsage(stats);
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+ }
+
+ protected virtual void LogUsage(ThreadPoolUsageStats stats)
+ {
+ string message = string.Format("[{0}] IOCP:(Busy={1},Min={2},Max={3}), WORKER:(Busy={4},Min={5},Max={6}), Local CPU: {7}",
+ DateTimeOffset.UtcNow.ToString("u"),
+ stats.BusyIoThreads, stats.MinIoThreads, stats.MaxIoThreads,
+ stats.BusyWorkerThreads, stats.MinWorkerThreads, stats.MaxWorkerThreads,
+ PerfCounterHelper.GetSystemCPU()
+ );
+
+ Console.WriteLine(message);
+ }
+
+ ///
+ /// Returns the current thread pool usage statistics for the CURRENT AppDomain/Process
+ ///
+ public static ThreadPoolUsageStats GetThreadPoolStats()
+ {
+ //BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
+ //If BusyThreads >= TP.GetMinThreads(), then threadpool growth throttling is possible.
+
+ int maxIoThreads, maxWorkerThreads;
+ ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxIoThreads);
+
+ int freeIoThreads, freeWorkerThreads;
+ ThreadPool.GetAvailableThreads(out freeWorkerThreads, out freeIoThreads);
+
+ int minIoThreads, minWorkerThreads;
+ ThreadPool.GetMinThreads(out minWorkerThreads, out minIoThreads);
+
+ int busyIoThreads = maxIoThreads - freeIoThreads;
+ int busyWorkerThreads = maxWorkerThreads - freeWorkerThreads;
+
+ return new ThreadPoolUsageStats
+ {
+ BusyIoThreads = busyIoThreads,
+ MinIoThreads = minIoThreads,
+ MaxIoThreads = maxIoThreads,
+ BusyWorkerThreads = busyWorkerThreads,
+ MinWorkerThreads = minWorkerThreads,
+ MaxWorkerThreads = maxWorkerThreads,
+ };
+ }
+
+ public void Dispose()
+ {
+ _disposed = true;
+ }
+ }
+
+ public struct ThreadPoolUsageStats
+ {
+ public int BusyIoThreads { get; set; }
+
+ public int MinIoThreads { get; set; }
+
+ public int MaxIoThreads { get; set; }
+
+ public int BusyWorkerThreads { get; set; }
+
+ public int MinWorkerThreads { get; set; }
+
+ public int MaxWorkerThreads { get; set; }
+ }
}
diff --git a/ThreadPoolMonitor/ThreadPoolMonitor.csproj b/ThreadPoolMonitor/ThreadPoolMonitor.csproj
index 2e39e95..9f8a8aa 100644
--- a/ThreadPoolMonitor/ThreadPoolMonitor.csproj
+++ b/ThreadPoolMonitor/ThreadPoolMonitor.csproj
@@ -1,60 +1,20 @@
-
-
-
-
- Debug
- AnyCPU
- {704D6A6C-711C-4332-9248-5F7009C1E071}
- Exe
- Properties
- ThreadPoolMonitor
- ThreadPoolMonitor
- v4.5
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+ Exe
+ netcoreapp3.1
+ true
+ true
+
+ win10-x64
+
+
+ false
+
+
+
+
+