做多线程时访问控件遇到的问题!望高手能解决! 输出窗口总显示 c# 在 System.NullReferenceException 中第一次偶然出现的请教高人有办法帮忙吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private static ManualResetEvent ev = new ManualResetEvent(false); //父、子线程同步 private Thread thread; public FrmMain(int _ip, ManualResetEvent _ev) { ip = _ip; ev = _ev; thread = new Thread(new ThreadStart(Scan)); lock (typeof(FrmMain)) { instanceCount++; } //同时存在的对象个数加一 } Scan 在哪儿声明的?instanceCount 在哪儿声明的?这点代码看不出什么来... private static int MaxThreadCount = 200; public static int instanceCount = 0; //同时存在的对象个数 public void Open() { System.Threading.Timer timer1 = new System.Threading.Timer(new TimerCallback(OnTimer), null, 0, 200); //200 ev.WaitOne(); } private static void OnTimer(object state) { lock (typeof(FrmMain)) { if ((FrmMain.instanceCount < MaxThreadCount) && (startIP <= endIP)) { while (startIP <= endIP) { FrmMain ck = new FrmMain(startIP, ev); ck.Scan(); if (FrmMain.instanceCount >= MaxThreadCount) break; startIP++; } } } } private void Scan() { try { string IP = "192.168.1." + this.ip; string Return = CPing.PingResult(IP); }catch{ } } C# 已经得到窗口句柄 怎么能移动窗口位置? c# 函数性能统计 c#数据库更新不了 FrameWork的Bug? 在线等!Access中如何将字符串转成日期型 一个关于datagrid的问题?? 什么叫发布啊 数据库问题 如何判断结果是否到是EOF?在线等 麻烦给俺扫下盲:“CrystalReport”是什么意思,以及它用途和特点,谢谢! 递归 请教正则表达式写法
private static ManualResetEvent ev = new ManualResetEvent(false); //父、子线程同步 private Thread thread;
public FrmMain(int _ip, ManualResetEvent _ev)
{
ip = _ip; ev = _ev; thread = new Thread(new ThreadStart(Scan)); lock (typeof(FrmMain)) { instanceCount++; } //同时存在的对象个数加一
}
private static int MaxThreadCount = 200;
public static int instanceCount = 0; //同时存在的对象个数 public void Open()
{
System.Threading.Timer timer1 = new System.Threading.Timer(new TimerCallback(OnTimer), null, 0, 200); //200
ev.WaitOne();
} private static void OnTimer(object state)
{
lock (typeof(FrmMain))
{ if ((FrmMain.instanceCount < MaxThreadCount) && (startIP <= endIP))
{
while (startIP <= endIP)
{
FrmMain ck = new FrmMain(startIP, ev);
ck.Scan();
if (FrmMain.instanceCount >= MaxThreadCount) break;
startIP++;
}
}
}
} private void Scan()
{
try
{ string IP = "192.168.1." + this.ip;
string Return = CPing.PingResult(IP); }
catch{ }
}