Skip to content

Commit

Permalink
fixing background execution issue with queries
Browse files Browse the repository at this point in the history
  • Loading branch information
edatkinvey committed Jan 20, 2015
1 parent 4c798ac commit 3ab6bf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions Kinvey-Xamarin/Offline/AbstractKinveyOfflineClientRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using KinveyUtils;
using System.Reflection;

namespace KinveyXamarin
{
Expand Down Expand Up @@ -213,9 +214,19 @@ public async override Task<T> ExecuteAsync(){
/// Kicks off the background sync thread
/// </summary>
public void kickOffSync(){
Task.Run (() => {
new BackgroundExecutor<T> ((Client)Client).RunSync ();
});
Type parameterType = typeof(T);
if (parameterType.IsArray) {
parameterType = parameterType.GetElementType ();
}

Type executor = typeof(BackgroundExecutor<>);
Type gen = executor.MakeGenericType (parameterType);

foreach (var ctor in gen.GetTypeInfo().DeclaredConstructors) {
Task.Run (() => {
ctor.Invoke (new object[1]{ (Client)Client });
});
}
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Kinvey-Xamarin/Offline/BackgroundExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public BackgroundExecutor (Client client)
this.dbpath = Path.Combine(client.filePath, "kinveyOffline.sqlite") ;
this.platform = client.offline_platform;
this.client = client;
RunSync ();
}

/// <summary>
Expand Down Expand Up @@ -93,8 +94,7 @@ private async void buildAndExecuteRequest(DatabaseHelper<T> handler, SQLTemplate

switch (verb) {
case "QUERY":

break;

T[] results = await appdata.GetAsync (id);
List<string> idresults = new List<string>();
foreach ( T ent in results){
Expand Down

0 comments on commit 3ab6bf7

Please sign in to comment.