Reputation: 2174
i am making an application in silverlight 3.0. In that application i have one public method as
public void DrawWavform()
{
Line[,] line = new Line[10,200];
line[i,j]= new Line();//i am getting error here of invalid thread access
//some operation
}
In application i am creating different threads as per user inputs and calling DrawWaveform method from that newly created thread. I want to parallel opeation.Please suggest me solution.Thanks in advance.
Upvotes: 0
Views: 6828
Reputation: 4232
Any operation changing the GUI must be executed on the UI thread. This can be done using the dispatcher:
Deployment.Current.Dispatcher.BeginInvoke( () =>
{
// update ui
});
or
(SomeDependencyObject).Dispatcher.BeginInvoke( () => { /* ... */ } );
Anyway, this code should be used very rarely and contain only UI related code. Executing expensive operations on the UI thread will cause your application to hang.
Upvotes: 7