1
Vote

Consideration on Async stuff

description

As you guys improve the Async APIs for Win8, etc. It would be nice if there was a bit more control/monitoring that I could query.

IE . IsAsyncUpdateInProgress()? CanTruncateTable()

I know the current SaveAsync returns a BW but it also keeps a local list of BW but it is private (_workers). I can create tracking details on the BW that is returned from SaveAsync but it seems like re-invention.

I need more help on protecting myself from myself :-). I haven't been able to do proper SaveAsyncs because I have iterative calls that are trying to delete records while they are being read etc.

Some help on queuing up async requests to help manage the ordering... ie I have two async requests in the front end that get kicked off but the first one ends up taking longer than the second one. I want to make sure my second process can't mess up the first one. (As I write this it just sounds like my code is bad)

But something along the line of

var token1 = SomeTable.LockForUpdate();
var token2 = SomeTable.LockForUpdate();

// Do asycSelect1
...

// do asyncSelect 2

MyAsyncDataLoad(xxx,yyy, token2, (a,b) =>
{
  // is the transaction locked
 while SomeTable.IsLocked(token2) { Sleep(10); }

  //not locked anymore
  SomeTable.SaveAsync(token2, newData.ToList())

  DataBindedProperty = newData;     
}

The above would be an example where I would make the UI wait for the unlock to be done but it would be nice if I know my UI can use the new data but I want to make sure all my saves are done in order then Sterling would just manage the async Save based on the lock token order.

Essentially a first lock, first commit mechanism. Then just like a normal transaction database (oracle) selects from the table (or cache) return the most recently committed data.

SomeTable.LockForUpdate() would likely need to have some timeout limits and then the ability to get the list of tokens and kill them etc.

Hopefully I was clear... I know there is a mix of bad practice on my end but I think there is room for some Sterling improvements to help not get into so much trouble.



Jack

comments

kayub wrote Mar 4, 2013 at 2:45 PM

I just reported some async test failures but I think I was able to fix at least one:

http://sterling.codeplex.com/workitem/16087

This might at least help with prevent issues writing to the same file concurrently.