Skip to content

Instantly share code, notes, and snippets.

View enRose's full-sized avatar
🎯
Focusing

Yini enRose

🎯
Focusing
  • Wellington, New Zealand
View GitHub Profile
static async Task WhenAllWithAsyncAndResultProcessInOneUnitStress()
{
var result = new Result();
async Task t(int taskId)
{
var r = await APICall(taskId);
result.Result1 = ProcessResult(r, taskId);
}
static async Task WhenAllWithAsyncAndResultProcessInOneUnit()
{
var result = new Result();
async Task t1()
{
var r = await APICall1();
result.Result1 = ProcessResult1(r);
}
static async Task WhenAllFinishesThenProcess()
{
var response = new Result();
var t1 = APICall1();
var t2 = APICall2();
var t3 = APICall3();
await Task.WhenAll(t1, t2, t3);
static async Task ProcessResultOneAtTheTime()
{
var r = new Result();
var t1 = APICall1();
var t2 = APICall2();
var t3 = APICall3();
r.Result3 = ProcessResult3(await t3);
r.Result2 = ProcessResult2(await t2);
static async Task ProcessResultOneAtTheTime()
{
var r = new Result();
var t1 = APICall1();
var t2 = APICall2();
var t3 = APICall3();
r.Result1 = ProcessResult1(await t1);
r.Result2 = ProcessResult2(await t2);
static Result1Processed ProcessResult1(TaskResult1 r)
{
marker.Measure("Process result 1 start");
Thread.Sleep(50);
marker.Measure("Process result 1 end");
return new Result1Processed() {
FinalResult = r.APIResult1 + " processed"
static async Task<TaskResult1> APICall1()
{
marker.Measure("API call 1 start");
await Task.Delay(250);
marker.Measure("API call 1 end");
return new TaskResult1
{
// A gateway to all query routes:
public async Task<Data> Query(Guid userId, string queryRoute)
{
var eligibility = await CheckElligibility(userId).ConfigureAwait(false);
if (eligibility != Validity.OK) {
Analytics.LogUserStatus(
queryRoute,
eligibility
);
public enum QueryRoute
{
SpiderMan,
Thanos,
IronMan,
CaptainAmerica,
WandaMaximoff,
Thor
}
[RoutePrefix("users/{userId:Guid}/marvel-characters")]
[JwtAuthorizationFilter(Roles = "Users")]
public class MarvelController : ApiController
{
private readonly IQueryService queryService;
private readonly IMutateService mutateService;
private readonly IPostService postService;
public ApplicationController(
IQueryService getService,