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
Suraj Sararf
NA
12
8.2k
eror:DependencySource on same Thread as the DependencyObject
Feb 8 2015 2:11 AM
I got that error when i use a background worker.
error - Must create DependencySource on same Thread as the DependencyObject.
code:-
public FileView(string path)
{
InitializeComponent();
loadlist(path);
listview.ItemsSource = vh.list();
}
Variableholder vh=new Variableholder();
BackgroundWorker bworker = new BackgroundWorker();
public void loadlist(string path)
{
bworker.WorkerSupportsCancellation = true;
bworker.WorkerReportsProgress = true;
bworker.DoWork += bworker_Explorer;
bworker.ProgressChanged += bworker_AddItem;
bworker.RunWorkerCompleted += worker_RunWorkerCompleted;
bworker.RunWorkerAsync(path);
}
public void bworker_Explorer(object sender,DoWorkEventArgs e)
{
ParallelOptions po = new ParallelOptions();
po.MaxDegreeOfParallelism = 10;
Parallel.ForEach(e.Argument.ToString().Split(','),po, speratepath =>
{
......
});
}
public void bworker_AddItem(object sender,ProgressChangedEventArgs e)
{
if (e.UserState != null)
{
vh.list().Add(e.UserState as MusicTags);
}
}
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
.......
}
private void listview_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
object o = listview.SelectedItem;
string filepath = (o as MusicTags).Filepath;
itemscontrol.ItemsSource = vh.list().Where(s => s.Filepath == filepath);
}
what i do?
Reply
Answers (
0
)
How to get or set a frame using taglib# in mp3
How to display data from webservice?