public static void RegisterCancellationToken(this ExtendableOptions options, CancellationToken cancellationToken)
        {
            var extensions = options.GetExtensions();

            RequestResponseStateLookup.State state;
            if (extensions.TryGet(out state))
            {
                state.CancellationToken = cancellationToken;
            }
            else
            {
                state = new RequestResponseStateLookup.State
                {
                    CancellationToken = cancellationToken
                };
            }
            extensions.Set(state);
        }
Пример #2
0
        static RequestResponseStateLookup.State RegisterTokenSource(this ExtendableOptions options, TaskCompletionSourceAdapter adapter)
        {
            var extensions = options.GetExtensions();

            RequestResponseStateLookup.State state;
            if (extensions.TryGet(out state))
            {
                state.TaskCompletionSource = adapter;
            }
            else
            {
                state = new RequestResponseStateLookup.State
                {
                    TaskCompletionSource = adapter,
                    CancellationToken    = CancellationToken.None
                };
            }
            extensions.Set(state);
            return(state);
        }