Skip to content

Instantly share code, notes, and snippets.

@manureini
Created March 10, 2023 00:41
Show Gist options
  • Save manureini/71b0c6384b561179f68bcb28d5781b43 to your computer and use it in GitHub Desktop.
Save manureini/71b0c6384b561179f68bcb28d5781b43 to your computer and use it in GitHub Desktop.
internal class Program
{
static async Task Main(string[] args)
{
var task1 = CheckUrl("http://localhost:5000/api/Job");
var task2 = CheckUrl("http://localhost:5000/api/Department");
var task3 = CheckUrl("http://localhost:5000/api/Employment?$filter=Event%2FId%20eq%20d95da18c-2fdf-4574-b8d1-c06d5b080e57&$skip=0&$top=10&$expand=Person,ApplicationShiftAssignments($expand=Shift($expand=Job))");
await task1;
await task2;
await task3;
}
protected static async Task CheckUrl(string pUrl)
{
var json2 = await Run(pUrl);
await Parallel.ForEachAsync(new int[10000],
new ParallelOptions()
{
MaxDegreeOfParallelism = 20
},
async (i, c) =>
{
var pjson2 = await Run(pUrl);
Console.WriteLine(pUrl);
if (pjson2 != json2)
{
throw new Exception();
}
}
);
}
protected static async Task<string> Run(string pUrl)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "...");
var response = await client.GetAsync(pUrl);
return await response.Content.ReadAsStringAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment