主窗体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;
}
}}

解决方案 »

  1.   

    Form1下已经调用了InitDevice
    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)) ;
    }
      

  2.   

    应该不是timer的问题,你调试一下,断点能进去么
      

  3.   

    各位高手请支招呀,Timer.Enable已经为True,但Timer设置的Interval时间到后Tick事件没被触发。
      

  4.   

    没有太多的细看代码.TIMEER不会有什么问题.有没有是什么线程和TIMEER之间的一些细节的问题
    我个人想哦.
      

  5.   

    在另一个线程中不能直接调用界面控件,要用invoke方法
      

  6.   

    现在估计要集中处理线程问题了,invoke方法没用过,谁能举个简单点的例子?
      

  7.   

    >>>>>你的Timer的Tick代码在哪儿?
      

  8.   

    还没人回答?
    回 "Timer的Tick代码在哪儿":
    int i=0;
    i++;//设个断点,啥也别干,只需要知道它执行到了这里就行
      

  9.   

    再说一遍,你不能在控件所在线程以外的线程调用主线程里的控件,可以使用控件自带的invoke 方法,调用代理。
      

  10.   

    Timer的Tick代码在哪儿":   根本就不会执行的
    你换成系统的Timer 控件然后就会执行
    我以前做过就出现过你现在的问题改
    成m_timerEquipment_Elapsed就可以了
      

  11.   

    以上回答均不是解决问题,最多也只是给出了某种方法,现在实在想不出应该如何结贴了,只好提出这样的问题:
    如何简单地使用 invoke 方法。
    谁能给出一个 invoke 方法的简单例子我就把分结给谁,希望大家不要回个MSDN上有例子或网上随便搜一下就有的答案了。
      

  12.   

    有谁见到此贴后请抄一个  使用 invoke 方法 的例子回贴,好让我结贴,好吗?
      

  13.   

    参看
    http://blog.csdn.net/knight94/archive/2006/03/16/626584.aspx