Question: C# Create a class named Dot that contains a public method named ShowDot . The method should take no parameters. The class contructor should take

C#

Create a class named Dot that contains a public method named ShowDot. The method should take no parameters. The class contructor should take a CancellationToken and a ManualResetEvent as parameters and save them into class fields.

The ShowDot method is to be run in a separate thread. The method must ensure that when cancel is signaled in the cancellation token, the thread is interrupted. Then, as long as cancellation is not requested, the thread should repeatedly wait on the manual reset event, write a dot ('.') to the console and then sleep for 1 second. If the thread is interrupted, it should exit (end).

Create a class named Dash that contains a public method named ShowDash. The method should take an object parameter that contains a CancellationToken and a ManualResetEvent (passed using a tuple).

The ShowDash method is to be run in a separate thread. The method must ensure that when cancel is signaled in the cancellation token, the thread is interrupted. Then, as long as cancellation is not requested, the thread should repeatedly wait on the manual reset event, write a dash ('-') to the console and then sleep for 3 seconds. If the thread is interrupted, it should exit (end).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!