I need some suggestion on OOD. Below is my situation.
Class A{
private B service_;
private StopWatch timer_;
private Const int MinTimeToWait;
public SomeOperation(){
timer_.start();
//call another method on service_ async and subsribe to event for callback
}
private SomeOperationCallback()
{
timer_.stop();
int elapsedTime = timer_.elapsedTime();
if(elapsedTime < MinTimeToWait)
Thread.sleep(MinTimeToWait - elapsedTime)
//Continue after thread resumes
}
}
I have a class that fires an async operation, and after the async operation returns I need to check if the asycn operation returned in less than the MinTimeToWait, if yes wait for the MinTimeToWait completes and then proceed with other operations.
Now, am doing the right thing by including the logic to check the times and wait in the SomeOperationCallback, or should I create a new class that encapsulates the logic and StopWatch and use that class to do this check and wait?
Thanks in advance for your replies.