public static Task <T> Deserialize <T>(string filename, Core.GHMattiTaskScheduler scheduler) => Task.Factory.StartNew(() => { XmlSerializer serializer = new XmlSerializer(typeof(T)); StreamReader reader = new StreamReader(Path.Combine("resources", resourceName, "xml", filename)); T res = (T)serializer.Deserialize(reader); reader.Close(); return(res); }, CancellationToken.None, TaskCreationOptions.None, scheduler);
public MySQL(string conn, bool debug, Core.GHMattiTaskScheduler taskScheduler) { connectionString = conn; Debug = debug; queryScheduler = taskScheduler; connectionString += ";AllowUserVariables=true"; using (Connection db = new Connection(connectionString)) { } }
/// <summary> /// Constructor, should be called in the task scheduler itself to avoid hitches /// </summary> /// <param name="mysqlSettings"></param> /// <param name="taskScheduler"></param> public MySQL(MySQLSettings mysqlSettings, Core.GHMattiTaskScheduler taskScheduler) { settings = mysqlSettings; settings.Apply(); queryScheduler = taskScheduler; // Cannot execute that connection in on the server thread, but we need to test if the connection string is actually correct // This will cause a hitch if the constructor is not put in a Task on a different thread using (Connection db = new Connection(settings.ConnectionString)) { } }
public MySQL(string server, string port, string databasename, string username, string password, bool debug, Core.GHMattiTaskScheduler taskScheduler) { connectionString = String.Format("SERVER={0};PORT={1};DATABASE={2};UID={3};PASSWORD={4}", server, port, databasename, username, password ); Debug = debug; queryScheduler = taskScheduler; // Cannot execute that connection in on the server thread, but we need to test if the connection string is actually correct // This will cause a hitch if the constructor is not put in a Task on a different thread using (Connection db = new Connection(connectionString)) { } }
public MySQL(string server, string port, string databasename, string username, string password, bool debug, Core.GHMattiTaskScheduler taskScheduler) { connectionString = String.Format("SERVER={0};PORT={1};DATABASE={2};UID={3};PASSWORD={4}", server, port, databasename, username, password ); Debug = debug; queryScheduler = taskScheduler; Connection db = new Connection(connectionString); db.connection.Close(); }