Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following C# program ThreeJobs.cs performs three slow operations JobA, JobB, and JobC sequentially. The output of JobA is needed in order to run JobB.

The following C# program ThreeJobs.cs performs three "slow" operations JobA, JobB, and JobC sequentially. The output of JobA is needed in order to run JobB. Revise the program to run the operations asynchronously. You should start JobA and JobC concurrently, then start JobB as soon as the results from JobA are available. namespace ThreeJobs { internal class Program { static void Main(string[] args) { Console.WriteLine("Begin"); int na = JobA(1); Console.WriteLine("JobA " + na); int nb = JobB(na); Console.WriteLine("JobB " + nb); int nc = JobC(2); Console.WriteLine("JobC " + nc); Console.WriteLine("Done"); }

static int JobA(int n) { Task.Delay(2000).Wait(); return 2*n; } static int JobB(int n) { Task.Delay(1000).Wait(); return 3*n; } static int JobC(int n) { Task.Delay(2500).Wait(); return 4 * n; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What is a verb?

Answered: 1 week ago