public async void executeSql() { QueryRunning = true; foreach (string statement in sqlList()) { if (cancelSql == true) { cancelSql = false; break; } string error = string.Empty; System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); DateTime dateTime = DateTime.Now; if (string.IsNullOrEmpty(statement) == false) { try { if (statement.ToUpper().Substring(0, statement.IndexOf(' ')).Contains("SELECT")) { ResultData = await connection.GetResultSetTask(statement); } else { sqlCount = await connection.ExecuteUpdate(statement); } } catch (Exception ex) { error = ex.Message; } finally { sw.Stop(); elapsedTime = sw.Elapsed.ToString(@"hh\:mm\:ss\.ffff"); await FormatOutput(statement, dateTime.ToString(), error); cancelSql = false; } } } QueryRunning = false; }