amazon-archives / aws-sdk-xamarin

AWS Mobile SDK for Xamarin (Beta)
Apache License 2.0
45 stars 18 forks source link

Support of asynchronous DynamoDB LoadTable() #17

Closed henrynacho closed 9 years ago

henrynacho commented 9 years ago

Is there an asynchronous load table API that honors a cancellation token? Something like BatchWrite.ExecuteAsync() that returns a task that I can wait on with a token.

I have a task that needs to be cancelled when the app goes to background But it is getting caught in the LoadTable() call.

tawalke commented 9 years ago

For clarity, would you show me your code example and what behavior you desire.

Sent from my Windows Phone


From: Henry Kwokmailto:notifications@github.com Sent: ‎2/‎20/‎2015 1:42 PM To: awslabs/aws-sdk-xamarinmailto:aws-sdk-xamarin@noreply.github.com Subject: [aws-sdk-xamarin] Support of asynchronous DynamoDB LoadTable() (#17)

Is there an asynchronous load table API that honors a cancellation token? Something like BatchWrite.ExecuteAsync() that returns a task that I can wait on with a token.

I have a task that needs to be cancelled when the app goes to background But it is getting caught in the LoadTable() call.


Reply to this email directly or view it on GitHub: https://github.com/awslabs/aws-sdk-xamarin/issues/17

henrynacho commented 9 years ago

Suppose I have a background Task that does this:

public void UploadData (CancellationToken token) { Client = new AmazonDynamoDBClient (credentials, config); myDataTable = Table.LoadTable (Client, "MyData"); <<<<< while (true) { // Read data from db and format it into Document var task = myDataTable.PutItemAsync (data); task.Wait (token); } }

If I am at a location where I have problem reaching the network (but I may have LAN connectivity), this task will be stuck in LoadTable() and if the iOS app goes to background and I need to cancel the task, it may not get out in time. (The network timeout is often longer than iOS background fetch run time.)

My request is that LoadTable() or an async version of LoadTable accepts a cancellation token like:

myDataTable = Table.LoadlTableAsync (Client, "MyData", token);

or create a Task < Table > like PutItemAsync:

var tableTask = Table.LoadTableAsync (Client, "MyData"); tableTask.Wait (token); myDataTable = tableTask.Result;

Then, I can use my token to cancel this task in a timely manner.

tawalke commented 9 years ago

Thanks for the explanation. Let me investigate this, give me a little time to see what I can come up with. I want to consider some architectural decision points around this for async to be inline with iOS and also consider usage from AWS Unity to see if BFTask support is there.

If I can create an interim solution for you, in the meantime I definitely will. I will follow-up with a response by EOW even if I don’t have a concrete solution to give you a heads up.

Thanks,

TEW

Sent from Windows Mail

From: Henry Kwok Sent: ‎Saturday‎, ‎February‎ ‎21‎, ‎2015 ‎7‎:‎18‎ ‎PM To: 'awslabs/aws-sdk-xamarin' Cc: Tara Walker

Suppose I have a background Task that does this:

public void UploadData (CancellationToken token) { Client = new AmazonDynamoDBClient (credentials, config); myDataTable = Table.LoadTable (Client, "MyData"); <<<<< while (true) { // Read data from db and format it into Document var task = myDataTable.PutItemAsync (data); task.Wait (token); } }

If I am at a location where I have problem reaching the network (but I may have LAN connectivity), this task will be stuck in LoadTable() and if the iOS app goes to background and I need to cancel the task, it may not get out in time. (The network timeout is often longer than iOS background fetch run time.)

My request is that LoadTable() or an async version of LoadTable accepts a cancellation token like:

myDataTable = Table.LoadlTableAsync (Client, "MyData", token);

or create a Task like PutItemAsync: var tableTask = Table.LoadTableAsync (Client, "MyData"); tableTask.Wait (token); myDataTable = tableTask.Result;

Then, I can use my token to cancel this task in a timely manner.

— Reply to this email directly or view it on GitHub.

tawalke commented 9 years ago

Hi:

This Beta SDK should now be migrated to use the AWS SDK for .NET with Xamarin has been released. As noted, this release is under AWS SDK for .NET and is in Developer Preview. The Xamarin SDK repo has the latest links for this update, as well as, the updates for the updated NuGet packages.

This should resolve you issue as this has the updated services and codebase desired. See links below: https://github.com/aws/aws-sdk-net https://github.com/aws/aws-sdk-net#nuget-packages