定时器在这里的作用是什么

发布于 2024-09-15 08:25:09 字数 1139 浏览 1 评论 0原文

这里的代码计时器的实际作用是什么,,另一件事是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())
            {

            }
    }
}

here the code what is the actual role of timer,,other thing is which if(saving) will trigger first ,if modification not happened means server fail..Is there any relation with thread..

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())
            {

            }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱本泡沫多脆弱 2024-09-22 08:25:10

阅读代码中的注释。

就是等待一切都正确绘制之后再做定时器事件中的动作。
Application.DoEvents() 有时用于类似的“等待”。

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

Read the comments in the code.

It is to wait for everything to be drawn correctly before doing the action in the timer event.
Application.DoEvents() is sometimes used for similar "waiting".

I guess that the timer interval is 1 millisecond.

雪落纷纷 2024-09-22 08:25:10

等待对话框显示以便(保存?)在显示对话框时执行某些操作似乎是一种不好的方法。

it's look like it is a bad way to wait for a dialog to be display in order (saving?) to do something when the dialog is displayed.

悍妇囚夫 2024-09-22 08:25:09

我们在这里唯一的线索是 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.

显然初始化顺序有问题。它闻起来有点像黑客,但我们没有看到足够的代码来决定到底是什么。

The only clue we have here is the XML comment:

/// 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.

Apparently there is a problem with the sequence of initialization. It smells a bit like a hack, but we don't see enough code to decide what exactly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文