【发布时间】:2014-05-16 03:45:59
【问题描述】:
我创建了一个 SNMP 扫描器并将 SNMP 值存储在哈希表中,如下所示:
SNMPObject[] s = new SNMPObject[4];
s[0] = new SNMPObject("1.3.6.1.2.1.1.5.0"); // name
s[1] = new SNMPObject("1.3.6.1.2.1.1.1.0"); // desc
s[2] = new SNMPObject("1.3.6.1.2.1.1.6.0"); // location
s[3] = new SNMPObject("1.3.6.1.2.1.43.10.2.1.4.1.1"); // count
SNMPAgent snmpAg = new SNMPAgent(newAddress, "public", "public");
Hashtable ht = snmpAg.getValues(s);
我在进程后面的线程中运行扫描。并检索哈希表值:
if (InvokeRequired)
{
this.Invoke(new MethodInvoker(delegate
{
//load the hashtable to datagridview
//Check if location value is empty.
if (!ht.ContainsValue(3)) //check condition did not working.
{
//do Set SNMP command
}
else
{
//do some other operation
}
}));
}
现在我希望条件检查位置是否不包含值。我想做 SET 操作。
但问题是我的 if (!ht.ContainsValue(3)) 条件不起作用。
即使ht.ContainsValue(3) 包含值,它仍然会执行设置操作。可以请教一下吗?
【问题讨论】: