2010-08-18 4 views
0

여기 타이머의 실제 역할은 무엇입니까? 다른 일은 수정이 발생하지 않으면 서버가 실패했을 때 (저장) 먼저 트리거됩니다. 스레드와 어떤 관계가 있습니까?여기에 타이머의 역할은 무엇입니까

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

코드의 주석을 읽으십시오.

타이머 이벤트에서 작업을 수행하기 전에 모든 것이 올바르게 그려지기를 기다리는 것입니다. Application.DoEvents()가 유사한 "대기 중"으로 사용되기도합니다.

나는 타이머 간격이 1 밀리 초라고 생각한다.

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

은 분명히 초기화의 순서에 문제가있는 것입니다 :

+0

예 당신은 정확합니다. – peter

+1

글쎄, 양식이 완전히로드 될 때까지 실행을 숨기는 해킹 패턴입니다. –

0

대화 상자가 표시 될 때 뭔가를 수행하기 위해 대화 상자가 표시 될 때까지 기다리는 나쁜 방법입니다 (저장 하시겠습니까?).

1

우리가 여기있는 유일한 단서는 XML 주석이다. 해킹과 같은 냄새가 있지만 정확히 무엇을 결정할 충분한 코드가 보이지 않습니다.

관련 문제