Skip to content

Instantly share code, notes, and snippets.

@mikhailshilkov
Created December 12, 2018 12:34
Show Gist options
  • Save mikhailshilkov/6565f25f2457a207112792ab8cf45815 to your computer and use it in GitHub Desktop.
Save mikhailshilkov/6565f25f2457a207112792ab8cf45815 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
namespace sendQueue
{
class Program
{
static void Main(string[] args)
{
ServicePointManager.UseNagleAlgorithm = false;
SendStuff(0, 100000, 50);
Console.WriteLine("Done!");
}
private static void SendStuff(int min, int max, int parallel)
{
var storageAccount = CloudStorageAccount.Parse("redacted");
var queueClient = storageAccount.CreateCloudQueueClient();
var name = "myqueue";
var queue = queueClient.GetQueueReference(name);
for (int i = min; i < max / parallel; i++)
{
var messages = Enumerable.Range(0, parallel).Select(j => new CloudQueueMessage((i* parallel + j).ToString()));
var tasks = messages.Select(queue.AddMessageAsync);
Task.WaitAll(tasks.ToArray());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment