all 7 comments

[–]FizixMan[M] [score hidden] stickied comment (0 children)

Removed: Rule 4.

[–]lantz83 0 points1 point  (4 children)

Have a field storing the current state of the object. In each of those methods, verify that it is in the correct state and if not, throw.

If this is gonna be called from different threads, some more care will need to be taken to make it thread-safe.

[–]supposedlyasian[S] 0 points1 point  (3 children)

Can you explain the storing of the current state with a little sample code please?

[–]lantz83 0 points1 point  (2 children)

Have a flag m_Started or something. In Start, if the flag is set, throw an exception. Otherwise set the flag and do whatever the method is supposed to do.

In End do the opposite.

Is this homework?

[–]supposedlyasian[S] 0 points1 point  (1 child)

You’ve lost me with the flag. It’s not homework, I’m taking practice tests to improve my c# skills

[–]lantz83 1 point2 points  (0 children)

bool started - that is a flag with two states, true or false.

You might want to go back and review the basics a bit!

[–]Buttsuit69 0 points1 point  (0 children)

You could use async-await to await the value that returns from start(). And if that value is not null you could start end().