1. I am trying to use the SQLite Libray in my extension. I'm unsure as to why, but for some reason my delegate sometimes gets called and sometimes it doesn't. I know this because 'wait' timesout about 70% of the time. Below in the first snippest is how the library is initialised. The connection to the database is in 'open' state.
    I tried loading it directly from oxide, but i was getting a "Null reference" exception.
    'Databases' is a dictionary containing instances of my class 'database' which inherits from a class that implements the first snipest.

    The second snipest is the execution of the query, the catch statement is never executed since nothing prints to the console, and it doesn't seem like my delegate is ever invoked.

    Code:
            /// <summary>
            /// An instance of Sqlite Lib
            /// </summary>
            private static readonly Core.SQLite.Libraries.SQLite Sql = new Core.SQLite.Libraries.SQLite();        private readonly object _sqlSync = new object();        /// <summary>
            /// Gets an instance of the MySql core library
            /// </summary>
            public Core.SQLite.Libraries.SQLite SqlProvider
            {
                get
                {
                    lock (_sqlSync)
                        return Sql;
                }
            }
    
    Code:
    var wait = new ManualResetEvent(false);Databases["someDb"].SqlProvider.Query(Sql.Builder.Append("SELECT version FROM DBVERSION"), Databases["someDb"].ConnectionHandler.Connection,
        delegate (List<Dictionary<string, object>> result)
        {
            try
            {
                if (result?.Count < 1)
                {
                    currentVersion = null;
                    wait.Set();
                    return;
                }            // set current version from record
                currentVersion = new Version((string)result[0]["version"]);
            }
            catch (Exception e)
            {
                Interface.Oxide.RootLogger.Write(LogType.Warning, "Couldn't read database version.");
    #if DEBUG
                Interface.Oxide.RootLogger.Write(LogType.Error, $"{e}");
    #endif
                currentVersion = null;
            }
            // Signal thread to contiue
            wait.Set();
        });wait.WaitOne(ServerConfig.Timeout * 1000);