Select to view content in your preferred language

BackgroundWorker and Graphics

662
2
Jump to solution
08-19-2012 07:21 PM
LanceCrumbliss
Frequent Contributor
Hello,

To keep the map and the progress bar responsive while generating a couple hundred point graphics in code-behind with a handful of calculated attributes, I'm trying to do it in a background worker thread using the backgroundworker class.  However, even this single line

Dim g As New Graphic


as the first and only line in the RunWorkerAsync handler, a cross thread error is generated. 

I use the backgroundworker class in other ESRI silverlight projects and it's really handy.  However, this is the first time trying to generate graphics.  Is this just not possible?

Lance
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
As a graphic contains an UI element, it needs to be created in the UI thread.

If you have lot of calculated attributes, you can do it in a background thread but you need to store the results in an intermediate structure. Then you need to come back to the UI thread to create the graphics.

View solution in original post

0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
As a graphic contains an UI element, it needs to be created in the UI thread.

If you have lot of calculated attributes, you can do it in a background thread but you need to store the results in an intermediate structure. Then you need to come back to the UI thread to create the graphics.
0 Kudos
LanceCrumbliss
Frequent Contributor
Thanks D.  in hindsight that should have been obvious.  and thanks for the idea.

Lance
0 Kudos