API verbs for an interruptible operation
- by 280Z28
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 I should include 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.