ios: Handle expensive operations in a background thread

If we handle them in the main thread, then the UI blocks, especially
when generating a new SSH key.
This commit is contained in:
Vishesh Handa
2019-10-11 16:00:14 +02:00
parent fbb1b12cb2
commit 17b13e9f00

@ -52,17 +52,17 @@ static FlutterMethodChannel* gitChannel = 0;
result(filesDir);
}
else if ([@"gitClone" isEqualToString:method]) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleMethodCallAsync:call result:result];
});
}
else if ([@"gitPull" isEqualToString:method]) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleMethodCallAsync:call result:result];
});
}
else if ([@"gitPush" isEqualToString:method]) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleMethodCallAsync:call result:result];
});
}
@ -189,7 +189,7 @@ static FlutterMethodChannel* gitChannel = 0;
}
}
else if ([@"generateSSHKeys" isEqualToString:method]) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self handleMethodCallAsync:call result:result];
});
}