Last active
November 19, 2021 02:20
-
-
Save Ganeshcse/4a352e744629f691125d991e0c428252 to your computer and use it in GitHub Desktop.
Async calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Session | |
{ | |
private List<UseCase> useCaseList; | |
public void ExecuteSession() | |
{ | |
foreach(var useCase in useCaseList) | |
{ | |
useCase.ExecuteUseCase(); | |
// Probelm is here. The next use case starts executing before completion of the previous use-case. | |
// Because I donot have a control over the Step execution. | |
// I am thinking to have AutoResetEvent in my UseCase class and the set from inside the Step class once it is finished execution. | |
} | |
} | |
} | |
class UseCase | |
{ | |
private List<Step> stepList; | |
public void ExecuteUseCase() | |
{ | |
var step = stepList[0]; | |
step.ExecuteStep(); | |
// I only need to call first step. Rest of the step execution taken care by Mediator pattern implementation. | |
// I am not displaying that here assuming it is not a concerned to my problem statement. | |
} | |
} | |
class Step | |
{ | |
public void ExecuteStep() | |
{ | |
// Do some work. | |
// Sometimes this step calls some other method which is async which I donot have control over it and does not | |
// even know that it is async. Its in some other library. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment