主窗体Form1下:
public void menuItem2_Begin()
{
//启动监控
menuItem2.Enabled=false;
menuItem3.Enabled=true;
myController.StartMonitoring() ;
Thread.Sleep(50);
timer1.Enabled = true ;
timer2.Enabled = true ;
timerReConnectServerLink.Enabled=true;
timerRecordWarning.Enabled=true;
}在 EsDevice class 下
public class EsDevice
{
public void InitCommunication(Form1 myForm)
{
form = myForm;
//用多线程初始化..类
if (!isConnectting && !ClientLinked)
{
isConnectting=true;
tempThread = new Thread(new ThreadStart(this.InitTcpClient)) ;
tempThread.Start() ;
}
}
private void InitTcpClient()
{
try
{
if (!ClientLinked)
{
...
ClientLinked=true;
isConnectting=false;
form.menuItem2_Begin();
//执行上面这句时Timer就是无法触发
//请问应该如何处理,如何解决
}
}
catch (Exception ex)
{
isConnectting=false;
}
}}
public void menuItem2_Begin()
{
//启动监控
menuItem2.Enabled=false;
menuItem3.Enabled=true;
myController.StartMonitoring() ;
Thread.Sleep(50);
timer1.Enabled = true ;
timer2.Enabled = true ;
timerReConnectServerLink.Enabled=true;
timerRecordWarning.Enabled=true;
}在 EsDevice class 下
public class EsDevice
{
public void InitCommunication(Form1 myForm)
{
form = myForm;
//用多线程初始化..类
if (!isConnectting && !ClientLinked)
{
isConnectting=true;
tempThread = new Thread(new ThreadStart(this.InitTcpClient)) ;
tempThread.Start() ;
}
}
private void InitTcpClient()
{
try
{
if (!ClientLinked)
{
...
ClientLinked=true;
isConnectting=false;
form.menuItem2_Begin();
//执行上面这句时Timer就是无法触发
//请问应该如何处理,如何解决
}
}
catch (Exception ex)
{
isConnectting=false;
}
}}
解决方案 »
- 有关进(线)程同步的问题
- C# WinForm中窗体控件缩放的问题
- 接收邮件超时
- 100分求购4国军旗原代码!!
- 100求助关于窗体的问题,谢谢了
- PDF能转SWF吗?回者有分,提供有效信息的虾米,另外奖200分
- C#调用C++ dll在客户的机子不能用
- C#子线程中如何添加消息处理?
- TCP Server 处理数据的一些问题??
- 请教微软专家和各位热心人,从WEB控件库中派生一个Datagrid自定义控件,能否实现以下功能呢?
- datagrid用c#(winform)能不能做出像Excel一样的单击单元格鼠标变成加号,然后鼠标向下拖动,下面的单元格自动填充成此单元格的值呀?
- 怎么给别人给分啊
public void InitDevice(MainCenter myCenter)
{
//对设备进行初始化
for(int i = 0 ; i < myCenter.myServerList.Count ; i++)
{
EsDevice myDevice = new EsDevice(((ServerView)myCenter.myServerList[i]).ServerID) ;
//将设备加入设备列表中
deviceList.Add(((ServerView)myCenter.myServerList[i]).ServerID,myDevice) ;
//初始化通信类
myDevice.InitCommunication(myForm) ;
}
monitorThread = new Thread(new ThreadStart(MonitoringDevice)) ;
}
我个人想哦.
回 "Timer的Tick代码在哪儿":
int i=0;
i++;//设个断点,啥也别干,只需要知道它执行到了这里就行
你换成系统的Timer 控件然后就会执行
我以前做过就出现过你现在的问题改
成m_timerEquipment_Elapsed就可以了
如何简单地使用 invoke 方法。
谁能给出一个 invoke 方法的简单例子我就把分结给谁,希望大家不要回个MSDN上有例子或网上随便搜一下就有的答案了。
http://blog.csdn.net/knight94/archive/2006/03/16/626584.aspx