Hi,
Just wondering if I run the following code, is this running on the main thread or on a background thread ?
I am guessing the following is running on the main thread ?
Since I am wanting to send the request to the MySQL database on a background thread (as I don't want the rest of my B4J app to lock while it's sending the request, in case it takes longer to send the request), would I be correct in saying the following code will run the SQL query on a background thread, and is it the correct way in doing it ?
Just wondering if I run the following code, is this running on the main thread or on a background thread ?
I am guessing the following is running on the main thread ?
B4X:
Sub SetValue(location As String, value As String) As String
Dim sql As SQL = pool.GetConnection
Try
'work with sql
sql.ExecNonQuery2("INSERT INTO Status (Location, Value) VALUES (?,?) ON DUPLICATE KEY UPDATE Value=?",Array (location,value,value))
Catch
'handle failure
Log(LastException.Message)
End Try
sql.Close
End Sub
Since I am wanting to send the request to the MySQL database on a background thread (as I don't want the rest of my B4J app to lock while it's sending the request, in case it takes longer to send the request), would I be correct in saying the following code will run the SQL query on a background thread, and is it the correct way in doing it ?
B4X:
Sub SetDeviceStatus(location As String, value As String) As String
pool.GetConnectionAsync("SQL1")
wait for SQL1_ConnectionReady (Success As Boolean, sql As SQL)
'work with sql
sql.ExecNonQuery2("INSERT INTO Status (Location, Value) VALUES (?,?) ON DUPLICATE KEY UPDATE Value=?",Array (location,value,value))
Catch
'handle failure
Log(LastException.Message)
End Try
End Sub