private bool TryEnableStats() { try { // Ignoring bandwidth measurement for loopbacks as it is meaningless anyway if (this.TargetIP == "127.0.0.1" || this.TargetIP == "::1") { return(false); } if (this.rawConnection is MIB_TCPROW_OWNER_MODULE) { rawrow = ((MIB_TCPROW_OWNER_MODULE)this.rawConnection).ToTCPRow(); TCPHelper.EnsureStatsAreEnabled((TCPHelper.MIB_TCPROW)rawrow); } else if (this.rawConnection is MIB_TCP6ROW_OWNER_MODULE) { rawrow = ((MIB_TCP6ROW_OWNER_MODULE)this.rawConnection).ToTCPRow(); TCP6Helper.EnsureStatsAreEnabled((TCP6Helper.MIB_TCP6ROW)rawrow); } statsEnabled = true; } catch { InboundBandwidth = 0; OutboundBandwidth = 0; IsAccessDenied = true; } return(false); }
private void EnableStats() { try { if (this.rawConnection is TCPHelper.MIB_TCPROW_OWNER_MODULE) { rawrow = ((TCPHelper.MIB_TCPROW_OWNER_MODULE) this.rawConnection).ToTCPRow(); TCPHelper.EnsureStatsAreEnabled((TCPHelper.MIB_TCPROW)rawrow); } else { rawrow = ((TCP6Helper.MIB_TCP6ROW_OWNER_MODULE) this.rawConnection).ToTCPRow(); TCP6Helper.EnsureStatsAreEnabled((TCP6Helper.MIB_TCP6ROW)rawrow); } } catch { IsAccessDenied = true; } }