2013-04-30 115 views
0
 protected override void OnResume() 
    { 
     base.OnResume(); 
        ProgressDialog progressDialog1 = ProgressDialog.Show(Parent, "", "Please wait...",false); 
     new Thread(new ThreadStart(() => { 

      RunOnUiThread(() => 
          { 

       try 
       { 
        string st=""; 
       } 
       catch (System.Exception ex) 
       { 

       } 
       progressDialog1.Dismiss(); 
      }); 
     })).Start(); 


    } 

當我在try catch塊中放置一個斷點時,進度對話框不可見。但相同的代碼在按鈕點擊事件內工作良好。做任何人都面臨同樣的問題?Android在OnResume中顯示ProgressDialog()

回答

0

感謝。

我得到了解決方案: - 我爲此創建處理程序。

static ProgressDialog progressDialog; 

    protected override void OnResume() 
    { 
     base.OnResume(); 
     progressDialog = ProgressDialog.Show(this, "", "Please wait..."); 
     loaddata(); 


    } 
    protected void loaddata(){ 
     new Thread(new ThreadStart(() => { 

       string st=""; // place a break point or make the thread wait 
       dialogHandler.SendEmptyMessage(0); 

     })).Start(); 

    } 

private Handler dialogHandler = new dialogHandlerHelper();

private class dialogHandlerHelper : Handler 
    { 
     public dialogHandlerHelper() 
     { 
     } 


     public override void HandleMessage(Message msg) 
     { 
      base.HandleMessage(msg); 
      progressDialog.Dismiss(); 
     } 
    }