我使用WPF,在我的主窗口,每當我嘗試做任何事情它給了我這個錯誤 「因爲不同的線程擁有它調用線程不能訪問此對象。」 這些例如,C#WPF異常
this.Visibility = Visibility.Visible
((Storyboard)this.FindResource("HideWindow")).Begin()
我嚴重不知道那是什麼,並幫助大量需要我不能執行我的代碼的第一個行。 更多信息: 我不能打開另一個窗口,讓我線程不是STA錯誤
LoginWindow objLoginWindow = new LoginWindow();
objLoginWindow.ShowDialog();
objLoginWindow = null;
這是個例外。
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace: at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Menupedia.LoadingWindow.OpenNewWindow() in c:\Users\xxxx\Desktop\menupedia\Menupediaa\Menupedia\LoadingWindow.xaml.cs:line 51
at Menupedia.LoadingWindow.TimeElapsed(Object sender, ElapsedEventArgs e) in c:\Users\xxxx\Desktop\menupedia\Menupediaa\Menupedia\LoadingWindow.xaml.cs:line 39
at System.Timers.Timer.MyTimerCallback(Object state)
但你不啓動一個單獨的線程? – Clemens
我試過使用不同的線程。好吧,它的工作,並讓我加載新的窗口。但另一種是左後衛有我不能把它藏在任何方式.. –
你的意思是不是執行故事板?你可能會提供更多關於你想達到的信息。 – Clemens