diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt index eeae055fc..8a1e05ce4 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -140,9 +140,11 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { MmkvManager.clearAllTestDelayResults() updateListAction.value = -1 // update all + val serversCopy = serversCache.toList() // Create a copy of the list + getApplication().toast(R.string.connection_test_testing) viewModelScope.launch(Dispatchers.Default) { // without Dispatchers.Default viewModelScope will launch in main thread - for (item in serversCache) { + for (item in serversCopy) { val config = V2rayConfigUtil.getV2rayConfig(getApplication(), item.guid) if (config.status) { MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, Pair(item.guid, config.content))