I have a long running task as part of my application. The task can be started, paused, resumed, and cancelled. I'm trying to find the best interface for these operations.
Two seem clear: Pause
and Cancel
. This leaves the start and resume operations. I could include both Start
and Resume
. This has the downside of either requiring the API consumer to check the state before starting/resuming the operation to call the right method, or making the methods aliases of each other. I'm thinking one possibility is using either Start or Resume, but I don't know which one is the most appropriate.
Does anyone have any examples in the .NET Framework of such behavior? I prefer to follow established patterns whenever they are available.
Edit: The most similar case I found so far is from the Workflow library. WorkflowInstance
has the methods:
- Abort
- Start
- Suspend
- Resume
- Terminate