Click here to Skip to main content
11,706,323 members (60,518 online)
Click here to Skip to main content
Add your own
alternative version

Tweaking WCF to build highly scalable async REST API

, 31 Jul 2011 CPOL 62.9K 948 79
You can build async REST API using WCF but due to some bug in WCF implementation it does not scale as you would want it to. Here's my journey with Microsoft's WCF team to explore the problem and find the right fix.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace AsyncServiceLibrary
    public class CustomAsyncResult<TState> : IAsyncResult
        private CustomState<TState> MyState;
        private IAsyncResult ExternalServiceResult;
        public CustomAsyncResult(IAsyncResult externalServiceResult, CustomState<TState> myState)
            this.ExternalServiceResult = externalServiceResult;
            this.MyState = myState;
        public IAsyncResult ExternalAsyncResult
            get { return this.ExternalServiceResult; }
        public CustomState<TState> CustomState
            get { return this.MyState; }
        #region IAsyncResult Members
        public object AsyncState
            get { return this.MyState.WcfState; }
        public WaitHandle AsyncWaitHandle
            get { return ExternalServiceResult.AsyncWaitHandle; }
        public bool CompletedSynchronously
            get { return ExternalServiceResult.CompletedSynchronously; }
        public bool IsCompleted
            get { return ExternalServiceResult.IsCompleted; }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Omar Al Zabir
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150819.1 | Last Updated 31 Jul 2011
Article Copyright 2011 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid