2009-10-28 20 views
0

我正在將我的舊應用程序從Windows窗體移動到WPF,並在此方法中遇到帶下劃線的錯誤。任何人都可以幫助解決DoEvents上的這些問題; SuspendLayout; ResumeLayout。我的老方法:在WPF應用程序中查找SQL服務器

private void FindDataBases() 
{ 
    string tempDBName = comboBoxDataBases.Text; 

    // ((FrameworkElement) this).Cursor = Cursors.WaitCursor; 
    ((FrameworkElement)this).Cursor = Cursors.Wait; 

    Application.DoEvents(); 

    SuspendLayout(); 

    DataSet dataBases = GetDatabases(); 

    ((FrameworkElement) this).Cursor = Cursors.Default; 
    Application.DoEvents(); 

    if ((dataBases != null) && (dataBases.Tables[0].Rows.Count > 0)) 
    { 
     comboBoxDataBases.DisplayMember = "DbName"; 
     comboBoxDataBases.DataSource = dataBases.Tables[0]; 

     if (comboBoxDataBases.FindStringExact(tempDBName) > 0) 
     { 
     comboBoxDataBases.SelectedIndex = comboBoxDataBases.FindStringExact(tempDBName); 
     } 
    } 
    else 
    { 
     comboBoxDataBases.DataSource = null; 
    } 

    ResumeLayout(); 

    // this.comboBoxDataBases.Focus(); 
} 
+0

你能告訴我們問題是什麼嗎?什麼是錯誤信息? – 2009-10-28 13:25:48

+0

正如我所說的DoEvents; SuspendLayout; ResumeLayout是事情,不再工作在WPF – Vytas 2009-10-28 14:14:38

+0

我只需要做WPF中的某種方式,就像我在發佈的方法中那樣。 – Vytas 2009-10-28 14:15:38

回答

0

我會盡量不阻止該應用程序,同時列舉數據庫。如何讓後臺線程完成這項工作?也許BackgroundWorker?當後臺線程啓動時鎖定UI,完成後解鎖UI。 AFAIK沒有WPF中的Application.DoEvents() ......

相關問題