Hi Elm,
After days searching, we finally find out the problem, the Projection is not thread safe, and it will go wrong in multithread mode sometimes, and here are two ways to solve your problem,
1), Override the class ManagedProj4Projection and add a locker, but this will not get the advantage of multithread.
public class MyProjection : ManagedProj4Projection
{
static object lockObject = new object();
protected override Vertex[] ConvertToInternalProjectionCore(double[] x, double[] y)
{
lock (lockObject)
{
return base.ConvertToInternalProjectionCore(x, y);
}
}
protected override Vertex[] ConvertToExternalProjectionCore(double[] x, double[] y)
{
lock (lockObject)
{
return base.ConvertToExternalProjectionCore(x, y);
}
}
}
public MyProjection GetLambert72ToGoogleProjection()
{
MyProjection _proj4Lambert72 = new MyProjection();
_proj4Lambert72.InternalProjectionParametersString = MyProjection.GetEpsgParametersString(31370);
_proj4Lambert72.ExternalProjectionParametersString = MyProjection.GetGoogleMapParametersString();
return _proj4Lambert72;
}
2), Set different instance of projection for each layers to avoid the multithread issue. e.g.
layer1.FeatureSource.Projection = GetLambert72ToGoogleProjection();
layer2.FeatureSource.Projection = GetLambert72ToGoogleProjection();
Hope it helps,
Edgar