Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, i have big problem about Backgroundworker, because i want to use it but it doesnt work i researched why it doesnt work and i found it ,it says your background worker uses a new thread, and this thread is different than the main UI thread ,that time i tried to use named Dispatcher.BeginInvoke method but it still doesnt work ,please help me ,i have to do it bu i couldnt. Background workers are not STA.
Posted
Updated 10-Apr-14 2:52am
v2
Comments
Animesh Datta 10-Apr-14 6:01am    
post your code
seycan 10-Apr-14 8:19am    
Yeah i am so soryy i use this code in Dowork of backgroundworker
private void workerThread_DoWork(object sender, DoWorkEventArgs e)
{
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {
ProgresBarWindow busy = new ProgresBarWindow();
busy.Show();
}));
Dispatcher.Run();
}
but it still explodes error about Ui thread
[no name] 10-Apr-14 6:50am    
Yes of course it works. Of course it uses a new thread, that is pretty much the whole purpose of using it to begin with. "it still doesnt work" does not tell us anything about your problem. We cannot see your code, read your screen or read your mind.
seycan 10-Apr-14 8:19am    
Yeah i am so soryy i use this code in Dowork of backgroundworker
private void workerThread_DoWork(object sender, DoWorkEventArgs e)
{
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {
ProgresBarWindow busy = new ProgresBarWindow();
busy.Show();
}));
Dispatcher.Run();
}
but it still explodes error about Ui thread

1 solution

Yeah i am so soryy i use this code in Dowork of backgroundworker
private void workerThread_DoWork(object sender, DoWorkEventArgs e)
{
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background, new Action(delegate {
ProgresBarWindow busy = new ProgresBarWindow();
busy.Show();
}));
Dispatcher.Run();
}
but it still explodes error about Ui thread
 
Share this answer
 
Comments
[no name] 10-Apr-14 8:20am    
In this particular case I don't have to be a mind reader to know what error it is that you are getting. You can't access UI components from non UI threads. The error message is telling you that. Use that ProgressChanged event.

And how is this a solution to your question anyway?
seycan 10-Apr-14 8:25am    
actually i have window that has busyindicator and it doesnt need to change anything it just turns like this picture http://www.telerik.com/help/wpf/media/radbusyindicator_features_delayed_display_010.png So i didnt use ProgressChanged

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900