TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mohsen hadaeghi
NA
3
2.1k
The calling thread cannot access this object because a diffe
May 10 2013 2:43 AM
Hi, I'm Mohsen. I have a bad problem in my code.Please help me for solve my problem.
Button button;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var threadstart = new Thread(new ThreadStart(Create));
threadstart.SetApartmentState(ApartmentState.STA);
threadstart.Start();
threadstart.Join();
threadstart = new Thread(new ThreadStart(Attach));
threadstart.Start();
threadstart.Join();
}
private void Create()
{
button = new Button();
button.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
button.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
}
private void Attach()
{
Dispatcher.BeginInvoke(new Action(() =>
{
Canvas.SetTop(button, 0); <===== The calling thread cannot access this object because a different thread owns it.
Canvas.SetLeft(button, 0);
MyCanvas.Children.Add(button);
}));
}
Reply
Answers (
2
)
Telerik Rad Date Picker
combobox binding json values