这里定时器的作用是什么

时间:2010-08-18 21:26:30

标签: c# timer

这里的代码是什么是定时器的实际作用,其他的是if(保存)将首先触发,如果修改没有发生意味着服务器失败..是否与线程有任何关系..

private void Dlg_Load(object sender, System.EventArgs e)
{
    // Set the message.
    if (Saving)
        eLabel.Text = Managers.ControlStrings.GetString("Saving");


    // Setup to receive events.
    Server.InfoReceived += new InfoEventHandler(Server_InfoReceived);
    Server.Received += new ServerStateEventHandler(Server_ServerStateReceived);

    // Start the timer to begin saving as soon as the dialog has completed setup.
    Timer.Start();
}

/// Handle the tick of the timer by stopping the timer and beginning the operation.  This allows
/// the dialog to come up fully before the operation is started; otherwise there are problems
/// closing the dialog.
/// </summary>
/// <param name="sender">Timer.</param>
/// <param name="e">Ignored.</param>
private void Timer_Tick(object sender, System.EventArgs e)
{
    string func = "Dlg.Timer_Tick";
    try
    {
        // Stop timer
        Timer.Stop();

        if (Saving)


            if (!Server.Modify())
            {

            }
    }
}

3 个答案:

答案 0 :(得分:1)

我们这里唯一的线索就是XML评论:

/// Handle the tick of the timer by stopping the timer and beginning the operation.  
/// This allows the dialog to come up fully before the operation is started; 
/// otherwise there are problems closing the dialog.

显然初始化序列存在问题。它闻起来有点像黑客,但我们没有看到足够的代码来确定究竟是什么。

答案 1 :(得分:0)

看起来好像等待按顺序显示对话框(保存?)以便在显示对话框时执行某些操作。

答案 2 :(得分:0)

阅读代码中的注释。

在定时器事件中执行操作之前,等待正确绘制所有内容。 Application.DoEvents()有时用于类似的“等待”。

我猜计时器间隔是1毫秒。