public EsentSession(Instance instance, Session session, JET_DBID dbid, string databasePath, IDisposeWaiters waiters, SingleThreadDispatcher dispatcher, bool isSecondary) { Instance = instance; _databasePath = databasePath; _waiters = waiters; _session = session; _database = dbid; IsSecondarySession = isSecondary; _dispatcher = dispatcher; }
public static async Task <EsentSession> CreateReadOnlySession(IEsentSession parentSession, IDisposeWaiters waiters) { var dispatcher = new SingleThreadDispatcher(); try { return(await dispatcher.QueueAction(() => { var session = new Session(parentSession.Instance); try { Api.JetAttachDatabase(session, parentSession.DatabaseFile, AttachDatabaseGrbit.None); JET_DBID dbid; Api.JetOpenDatabase(session, parentSession.DatabaseFile, string.Empty, out dbid, OpenDatabaseGrbit.None); // ReSharper disable once AccessToDisposedClosure return new EsentSession(parentSession.Instance, session, dbid, parentSession.DatabaseFile, waiters, dispatcher, true); } catch { session.Dispose(); throw; } })); } catch { dispatcher.Dispose(); throw; } }