2014-01-26 165 views
0

我正在使用下面的代碼,並希望光標將顯示在加載數據時爲什麼我不在屏幕上看到它?因爲目前沒有任何事情發生。 當我調試它,我看到代碼調用,但沒有發生在屏幕上...鼠標光標未顯示

onButtonCommand(){ 

      Application.Current.Dispatcher.BeginInvoke((Action)(() => 
      { 
       System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; 

      })); 

      //Get service Data 
      _Model.SerivceData(); 

      Application.Current.Dispatcher.BeginInvoke((Action)(() => 
      { 
       System.Windows.Input.Mouse.OverrideCursor = null; 
      })); 

....

回答

1

異步(使用的BeginInvoke)調用方法。反而同時調用(使用調用)。

Application.Current.Dispatcher.Invoke((Action)(() => 
{ 
    System.Windows.Input.Mouse.OverrideCursor = 
        System.Windows.Input.Cursors.Wait; 

})); 

BeginInvoke在調度程序中排隊委託,並將根據調度程序的優先級異步執行它。

+0

感謝我現在看到它投票了!但問題是,我打電話給服務,用戶有一個彈出窗口,他應該把用戶和通過,我看到它之前,但當數據是loeded我根本沒有看到它......當數據被解密時我甚至無法用光標在屏幕上移動,任何想法如何解決? –

+0

@John - 這是完全不同的問題(與鼠標光標無關)。要回答我們需要更多您發佈的代碼。請使用相關代碼單獨發佈問題以重現問題。 (請不要在意見中詢問跟原始問題無關的問題,否則你的問題不會在這裏介紹給更多的聽衆)。 –

+0

好的,謝謝Rohit! –