public QueryHandle CreateQuery() { var result = NativeMethods.get_query(this, out var nativeException); nativeException.ThrowIfNecessary(); var queryHandle = new QueryHandle(Root ?? this); queryHandle.SetHandle(result); return(queryHandle); }
public QueryHandle CreateQuery() { var queryHandle = new QueryHandle(Root ?? this); // At this point sh is invalid due to its handle being uninitialized, but the root is set correctly // a finalize at this point will not leak anything and the handle will not do anything // now, set the TableView handle... RuntimeHelpers.PrepareConstrainedRegions(); // the following finally will run with no out-of-band exceptions try { } finally { NativeException nativeException; var result = NativeMethods.get_query(this, out nativeException); nativeException.ThrowIfNecessary(); queryHandle.SetHandle(result); } // at this point we have atomically acquired a handle and also set the root correctly so it can be unbound correctly return(queryHandle); }