1

I have a question which I need pointers to how best to solve it.

So I have a Booking Class with 2 methods:

  1. StartBooking();
  2. GetBookingStatus.

These are the conditions to execute this function:

When a StartBooking() function is called and another thread or the same thread Calls the function again, it should throw BookingInProgressException. When GetBookingStatus() is called by another thread when it is in progress Should throw a ReadinProgressException. Calling GetBookingStatus() without calling StartBooking() should throw a NoStartBookingException.

Any pointers will be really helpful.

Chsiom Nwike
  • 484
  • 5
  • 11
  • What about mutex or lock? https://www.c-sharpcorner.com/UploadFile/1d42da/thread-locking-in-C-Sharp/ Usually there is scenario of blocking of execution of certain code until previous caller is finished and second thread is stopped on locker object. Another tool is SingleThreadApartment: https://ourcodeworld.com/articles/read/890/how-to-solve-csharp-exception-current-thread-must-be-set-to-single-thread-apartment-sta-mode-before-ole-calls-can-be-made-ensure-that-your-main-function-has-stathreadattribute-marked-on-it – VitezslavSimon Aug 28 '21 at 12:48
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 30 '21 at 07:16

0 Answers0