Created
December 24, 2012 13:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Table; | |
namespace AsyncSemaphore | |
{ | |
partial class Program | |
{ | |
static void InsertAsync001(CloudTable table, int start, int count) | |
{ | |
var tasks = Enumerable.Range(start, count).Select(async i => | |
{ | |
var e = new TableEntity(PKEY_STRS[i % PKEY_STRS.Length], i.ToString("D10")); | |
var insertOperation = TableOperation.Insert(e); | |
try | |
{ | |
await table.ExecuteAsync(insertOperation).ConfigureAwait(false); | |
if (i != 0 && i % 100000 == 0) | |
Console.Error.WriteLine(i); | |
} | |
catch (StorageException se) | |
{ | |
Console.Error.WriteLine("{0}, {1}", i, se.ToString()); | |
} | |
}).ToArray(); | |
Task.WhenAll(tasks); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment