Search code examples
c#multithreadingsqlgeometry

Is SqlGeometry.STUnion method thread safe?


Is SqlGeometry.STUnion method thread safe in .Net? MSDN


Solution

  • Decompiled body from sql 11.0 assembly using JustDecompile:

        [SqlMethod(IsDeterministic=true, IsPrecise=false)]
        public SqlGeometry STUnion(SqlGeometry other)
        {
            if (this.IsNull || other == null || other.IsNull || this.Srid != other.Srid)
            {
                return SqlGeometry.Null;
            }
            this.ThrowIfInvalid();
            other.ThrowIfInvalid();
            return SqlGeometry.Construct(GLNativeMethods.Union(this.GeoData, other.GeoData), this.Srid);
        }
    

    where SqlGeography.Construct and GLNativeMethods.GeodeticUnion are static methods, while others can't be deadlocked anywhere. None of the methods used is modifying the calling object, so yes - it's thread safe.