private static IObserver <T> CreateWorker <T>(
            ProgressToken token,
            IResponseRouter router,
            ISerializer serializer,
            Func <Exception, WorkDoneProgressEnd> onError,
            Func <WorkDoneProgressEnd> onComplete,
            IDisposable disposable)
        {
            return(Observer.Create <T>(
                       value => router.SendProgress(token.Create(value, serializer.JsonSerializer)),
                       error =>
            {
                if (onError != null)
                {
                    router.SendProgress(token.Create(onError.Invoke(error), serializer.JsonSerializer));
                }

                disposable.Dispose();
            },
                       () =>
            {
                var result = onComplete();
                if (result == null)
                {
                    disposable.Dispose();
                    return;
                }

                router.SendProgress(token.Create(result, serializer.JsonSerializer));
                disposable.Dispose();
            }));
        }
 private static IObserver <T> CreateWorker <T>(
     ProgressToken token,
     IResponseRouter router,
     ISerializer serializer,
     IDisposable disposable)
 {
     return(Observer.Create <T>(
                value => router.SendProgress(token.Create(value, serializer.JsonSerializer)),
                error => { disposable.Dispose(); },
                disposable.Dispose));
 }