【问题标题】:Is SqlGeometry.STUnion method thread safe?SqlGeometry.STUnion 方法线程安全吗?
【发布时间】:2014-04-23 10:39:56
【问题描述】:

.Net 中的 SqlGeometry.STUnion 方法线程安全吗? MSDN

【问题讨论】:

    标签: c# multithreading sqlgeometry


    【解决方案1】:

    使用 JustDecompile 从 sql 11.0 程序集反编译的主体:

        [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);
        }
    

    其中SqlGeography.ConstructGLNativeMethods.GeodeticUnion 是静态方法,而其他方法不能在任何地方死锁。使用的方法都没有修改调用对象,所以是的 - 它是线程安全的。

    【讨论】:

      【解决方案2】:

      怎么可能? SqlGeometry 似乎是不可变的——因此 2 个不可变类的输入应该是确定的输出。

      【讨论】:

      • 我不是很懂。我有超过 10 万个项目要合并,一个周期非常慢。
      猜你喜欢
      • 2013-03-31
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多