定时器在这里的作用是什么
这里的代码计时器的实际作用是什么,,另一件事是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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读代码中的注释。
就是等待一切都正确绘制之后再做定时器事件中的动作。
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.
等待对话框显示以便(保存?)在显示对话框时执行某些操作似乎是一种不好的方法。
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.
我们在这里唯一的线索是 XML 注释:
显然初始化顺序有问题。它闻起来有点像黑客,但我们没有看到足够的代码来决定到底是什么。
The only clue we have here is the XML comment:
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.