Beispiel #1
0
 public void Dispose()
 {
     if (m_handle != null)
     {
         m_handle.Dispose();
     }
 }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         m_handle.Dispose();
         m_clusterHandle?.Dispose();
     }
 }
        private static async ValueTask <IFdbDatabaseHandler> CreateDatabaseLegacyAsync(string?clusterFile, CancellationToken ct)
        {
            // In legacy API versions, you first had to create "cluster" handle and then obtain a database handle that that cluster.
            // The API is async, but the future always completed inline...

            ClusterHandle? cluster  = null;
            DatabaseHandle?database = null;

            try
            {
                cluster = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.CreateCluster(clusterFile),
                    h =>
                {
                    var err = FdbNative.FutureGetCluster(h, out var handle);
                    if (Fdb.Failed(err))
                    {
                        throw Fdb.MapToException(err) !;
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                database = await FdbFuture.CreateTaskFromHandle(
                    FdbNative.ClusterCreateDatabase(cluster, "DB"),
                    h =>
                {
                    var err = FdbNative.FutureGetDatabase(h, out var handle);
                    if (Fdb.Failed(err))
                    {
                        throw Fdb.MapToException(err) !;
                    }

                    return(handle);
                },
                    ct).ConfigureAwait(false);

                return(new FdbNativeDatabase(database, clusterFile, cluster));
            }
            catch (Exception)
            {
                database?.Dispose();
                cluster?.Dispose();
                throw;
            }
        }
 public void Dispose()
 {
     m_handle?.Dispose();
 }