Answers for "execute three methods synchronously"

C#
0

execute three methods synchronously

using System;
using System.Diagnostics;
using System.Threading;

var sw = new Stopwatch();
sw.Start();

f1();
f2();
f3();

sw.Stop();

var elapsed = sw.ElapsedMilliseconds;
Console.WriteLine($"elapsed: {elapsed} ms");

void f1() 
{
    Console.WriteLine("f1 called");
    Thread.Sleep(4000);
}

void f2() 
{
    Console.WriteLine("f2 called");
    Thread.Sleep(7000);
}

void f3() 
{
    Console.WriteLine("f3 called");
    Thread.Sleep(2000);
}
Posted by: Guest on October-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language