1

My project is required to be cross-platform, so I am using the C++ API for ArcObjects. My application creates a new thread which listens to a network socket broadcasting location information. I am attempting to read in the information and add points to my DynamicLayer. My problem comes when I try to use a new IPoint in the second thread. I can make the call:

IPointPtr newpoint(CLSID_Point);

But on the next line when I execute:

newpoint->PutCoords(x,y);

The application fails with a nonspecific error 'aborted'.

Relavant information: I am creating a new thread by calling pthread_create on a static method.

I have read the ESRI document on multithreading (which like the rest of the documentation is woefully absent of c++ specific information), but didn't see anything I thought could be the problem. Any thoughts?

7
  • 1
    Did you try using IGeometryBridge2? It's not geared towards IPoint objects, but I suppose you could have a multipoint with just one point in it. Jun 28, 2013 at 14:25
  • Thanks for the tip! This seems like exactly what I need! I'll give it a shot and post again when I have some results.
    – dykeag
    Jun 28, 2013 at 14:44
  • That pointer to the IGeometryBridge was probably the right answer for .NET programmers, but it seems that those of us stuck in C++ cannot properly utilize it because many of the method calls require a SAFEARRAY, which is not well supported in ESRI's API
    – dykeag
    Jul 1, 2013 at 13:13
  • Hmm, I thought the whole point of IGeometryBridge2 was to provide support for safe arrays. "The IGeometryBridge interface solves that problem allowing you to pass safe arrays instead." Jul 1, 2013 at 13:20
  • That is exactly the problem, I am having great difficulty constructing a SAFEARRAY within ESRI's environment. They provide us with an Array class (which I believe is supposed to encapsulate SAFEARRAY), but I was unable to add IPoint objects to it.
    – dykeag
    Jul 1, 2013 at 13:22

1 Answer 1

1

Solution: In each thread you MUST call ::AoInitialize(NULL) in order to use ArcObjects!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.