Skip to content

Instantly share code, notes, and snippets.

@nigel-sampson
nigel-sampson / gist:4498210
Created January 10, 2013 00:09
Returning Null
public class RetailersService : AppServiceBase
{
public async Task<IList<Retailer>> GetRetailersAsync()
{
return await BlobCache.LocalMachine.GetOrFetchObject("retailers", DownloadRetailersAsync);
}
private Task<IList<Retailer>> DownloadRetailersAsync()
{
IList<Retailer> retailers = Enumerable.Range(0, 20)
@nigel-sampson
nigel-sampson / gist:4027391
Created November 6, 2012 20:43
TaskScheduler
var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
SetUIThreadMarshaller(action =>
{
if (Window.Current != null)
action();
else
Task.Factory.StartNew(action, new CancellationToken(), TaskCreationOptions.PreferFairness, scheduler).Wait();
});