Select to view content in your preferred language

Adding points in a polyline

1044
1
11-15-2010 02:38 PM
MatsKarlsson
Occasional Contributor
Hi,
I am tracking a path of a target and want to visualize it with a poly line in real time.
I add new points to the poly line in a background worker thread. However, the polyline is not updated on the map display as new points are added.


The code below is executed in a thread and each time the variable currentPoint is updated to a new position:


//Update history graphic
     if (target.mHistoryGraphic == null) //happens only once....
     {
      mHistorySymbol    = Symbol.Line.Solid.Red;
      target.mHistoryGeometry   = new Polyline();     
      target.mHistoryGraphic = new Graphic(target.mHistoryGeometry, mHistorySymbol, target.mLabel + "History");
      target.mHistoryGraphic.Placement3D = Placement3D.AttachToSurface;
      target.mHistoryGeometry.AddPoint(new Point (0,0));
      target.mHistoryGeometry.AddPoint(new Point(1, 0));
      target.mHistoryGeometry.AddPoint(currentPoint);        //<---- I can see this part of the poly line displaying
      
     }
     else
     {     
     
                                             target.mHistoryGeometry.AddPoint(currentPoint);//<--- points added to the poly line is not shown! How should it be done?????
     }

Do I have to repopulate the polyline each time?


Thanks,
totte
0 Kudos
1 Reply
MichaelBranscomb
Esri Frequent Contributor
Hi,

ArcGIS Explorer objects can only be accessed on the thread in which they were created - in order to achieve your objective you'll need to serialize/deserialize as you pass the object between threads. See "Best practices for programming with a BackgroundWorker" for more information (http://help.arcgis.com/en/arcgisexplorer/1500/sdk/conceptualhelp/index.html#//000200000046000000).

Regards

Mike
0 Kudos