1
我正在WPF中開發一個twitter客戶端,我想使用backgroundworker來更新推文,但會導致此錯誤消息「調用線程無法訪問此對象,因爲不同的線程擁有它」。「調用線程不能訪問此對象,因爲不同的線程擁有它。」與Twitterizer
public NewTweet()
{
InitializeComponent();
this.MouseLeftButtonDown += (o, e) => DragMove();
worker.WorkerReportsProgress = true;
worker.DoWork += DoWork;
worker.RunWorkerCompleted += WorkerCompleted;
}
void DoWork(object sender, DoWorkEventArgs e)
{
TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(token, txttweet.Text);
System.Threading.Thread.Sleep(5);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
worker.RunWorkerAsync();
}
非常感謝。
[線程問題的可能的重複「調用線程不能訪問此對象,因爲不同的線程擁有它」。任何解決方案?](http://stackoverflow.com/questions/7684206/threading-issue-the-calling-thread-cannot-access-this-object-because-a-differen) – JasonMArcher