Operation Context Lifetime and Threading

The lifetime of the operation context, represented by a WS_OPERATION_CONTEXT handle, determines the lifetime of the properties it contains. Therefore, a context should only be used within the lifetime of the service operation or the callback to which its provided. The lifetime of a synchronous call is the execution of function itself. For an asynchronous call the lifetime ends once the asynchronous call is completed. The Service Model gives no guarantees about the context once the call is completed. The behavior of relying on operation context or any of its properties beyond its lifetime is undefined.

See also, the session based calculator example, SessionfullCalculatorServiceExample.

Threading Model

The operation context supports free threading, however this is true of the operation context itself and does not apply to any of the properties it contains.

When you register a cancel callback for a service operation through the WsRegisterOperationForCancel function, note that the first registration will succeed; setting the cancel callback multiple times, however, will fail.