API verbs for an interruptible operation

Posted by 280Z28 on Stack Overflow See other posts from Stack Overflow or by 280Z28
Published on 2010-06-07T15:10:50Z Indexed on 2010/06/07 15:12 UTC
Read the original article Hit count: 181

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about api