I solved the problem with a similar situation (i.e. the need to know if A was called immediately before C), having just a state station. Essentially, I built a state object using enum and a property to control / query the state.
When my equivalent A () was called, it would have to store a piece of business logic from a state indicating that A. had been called. If other methods (your B) were called, it would switch the state to one of several other states ( my situation was a bit more complicated), and then, when C () was called, part of the business logic was requested to determine if they were going to name some method D () that held the functionality "only if A was called".
I suspect there are several ways to solve this problem, but I liked the approach to the state computer that I took because it allowed me to expand the original binary situation to handle a more complex situation with several states.
I was fortunate that multithreading was not a problem in my case, because it tends to make things more interesting, but the state machine will probably work in this scenario as well.
Only my two cents.
source share