Skip to content

Instantly share code, notes, and snippets.

@RageshAntony
Created January 2, 2021 04:26
Show Gist options
  • Save RageshAntony/f2f9006df7bcae8974696ee6b8c6e622 to your computer and use it in GitHub Desktop.
Save RageshAntony/f2f9006df7bcae8974696ee6b8c6e622 to your computer and use it in GitHub Desktop.
sample code of courotine call
val scope = CoroutineScope(Job() + Dispatchers.Main)
// #1
scope.launch {
withContext(Dispatchers.IO) {
viewModel.delBill()
}
}
// #2
runBlocking {
withContext(Dispatchers.IO) {
viewModel.delBill()
}}
suspend fun delBill() { // suspend is redundant warning
var queryProc = ""
delXML.forEach {
queryProc += it.value
//Log.d(this.javaClass.simpleName, "delBill: ${queryProc}")
}
queryProc = "<NewDataSet>$queryProc</NewDataSet>"
Log.d(this.javaClass.simpleName, "delBill: ${queryProc}")
con?.deleteBills(queryProc,bills,result,date,page) // java file function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment