相关疑难解决方法(0)

从c#中的不同线程启动一个计时器

嗨我已经陷入了一些与计时器相关的问题.希望有人可以帮忙..

  1. 我有一个包含按钮的窗体
  2. 当我点击该按钮时,我启动参数化线程
Thread thread1 = new Thread(new ParameterizedThreadStart( execute2));
thread1.Start(externalFileParams);
Run Code Online (Sandbox Code Playgroud)
  1. 线程内的代码执行得很好
  2. 在这个线程的最后一行,我启动一个计时器

.

public void execute2(Object ob)
{
    if (ob is ExternalFileParams)
    {
        if (boolean_variable== true)
          executeMyMethod();//this also executes very well if condition is true
        else
        {
            timer1.enabled = true;
            timer1.start();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

5但是没有触发计时器的tick事件

我正在研究VS2008 3.5框架.我已经从工具箱拖动计时器并将其设置Interval为300也试图设置Enabledtrue/false方法timer1_Tick(Object sender , EventArgs e)但是它没有被解雇

任何人都可以建议我做错了什么?

c# multithreading timer visual-studio-2008

13
推荐指数
2
解决办法
4万
查看次数

标签 统计

c# ×1

multithreading ×1

timer ×1

visual-studio-2008 ×1