tags:

views:

69

answers:

2

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

            }
    }
}
A: 

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.

Baget
A: 

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.

Albin Sunnanbo
yes you are correct
peter
well, it's a hacky pattern to deffer execution until the form is completely loaded.
Albin Sunnanbo