With ArcEngine 9.3.1 in java (but I suppose, it's the same in .NET), I'm developping an application which loads a mxd file. This file contains about 20 layers with shapefile, JPG's, TIFF's files. This file is located on a remote server but accessible through windows share.
After instantiating a MapBean, I try to access some information on this object but I get an Exception "Argument is not a com object : null".
Here an extract of my code:
//some code initializing the engine
mapBean = new MapBean();
mapBean.setDocumentFilename("myMXD.mxd");
add("Center",mapBean); //adding into javax.swing.JComponent
//some Intructions
int count=mapBean.getLayerCount();
//count is 0 but after some time, it becomes the right value !!
So I tried to wait for some thread having finished their jobs in such way:
Thread thread;
Thread[] threadArray = new Thread[100];
int threadCount = Thread.enumerate(threadArray);
for (int threadIndex = 0; threadIndex < threadCount; threadIndex++)
{
try {
thread = threadArray[threadIndex];
if (thread.getName().startsWith("RetrieveThread")
|| thread.getName().startsWith("Image Fetcher") )
{
thread.join();
threadIndex = 0;
threadCount=Thread.enumerate(threadArray);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
But it doesn't really help.
Has someone an idea how to know when the MapBean is really ready with all his information ?
Thanks in advance,
Fabien
