private static void UpdateStats(object state) { ProcessTcpConnections p = (ProcessTcpConnections)state; p.Update(); Console.WriteLine("DataBytesIn:" + p.DataBytesIn + " DataBytesOut:" + p.DataBytesOut); }
static void Main(string[] args) { ProcessTcpConnections p = new ProcessTcpConnections(Process.GetCurrentProcess().Id); Timer timer = new Timer(UpdateStats, p, 0, 100); do { using (WebClient client = new WebClient()) { client.DownloadString("http://www.example.com"); } Console.ReadKey(true); // press any key to download again }while (true); }