This question might sound a bit stupid but here it goes.
I have two functions that can be called at any moment. The first function takes a snapshot, and the second one analyses the data taken from that snapshot. Of course if the user tries to analyse the snapshot before taking it, my application should throw an exception. I know the ArgumentOutOfRangeException that is generally thrown when……there is an invalid argument, but that is not really the case. Is there any in-built exception for this kind of cases, or will I have to use ArgumentOutOfRangeException?
Thanks
Sounds like an InvalidOperationException.
http://msdn.microsoft.com/en-us/library/system.invalidoperationexception.aspx
That said, if you can design your API so that you can’t get in this situation, that would be better. Something like (pseudo):
Like this, there’s no way to call them out of order.