kju-digital-solutions / dcsync

DC Sync Plugin
Apache License 2.0
1 stars 0 forks source link

Threading #8

Open leowin opened 8 years ago

leowin commented 8 years ago

plugins function (like searchDocuments) that take much processing time block the apps UI Thread. Please run them in a background thread like so:

- (void)myPluginMethod:(CDVInvokedUrlCommand*)command { // Check command.arguments here. [self.commandDelegate runInBackground:^{ NSString* payload = nil; // Some blocking logic... CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload]; // The sendPluginResult method is thread-safe. [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }]; }

Taken from https://cordova.apache.org/docs/en/3.0.0/guide/platforms/ios/plugin.html

WangYinXing commented 8 years ago

https://github.com/atkjumedia/dcsync/commit/215710aee450f32d8078635977d8a73ef0f9e500

done.