Beispiel #1
0
        public static Task FlushAsync(this HttpResponseBase response)
        {
            if (!response.IsClientConnected)
            {
                return(TaskAsyncHelper.Empty);
            }
#if NET45
            if (response.SupportsAsyncFlush)
            {
                return(Task.Factory.FromAsync((cb, state) => response.BeginFlush(cb, state), ar => response.EndFlush(ar), null));
            }
#endif
            try
            {
                response.Flush();
            }
            catch
            {
            }

            return(TaskAsyncHelper.Empty);
        }
Beispiel #2
0
        public static Task FlushAsync(this HttpResponseBase response)
        {
#if NET45
            if (response.SupportsAsyncFlush)
            {
                return(Task.Factory.FromAsync((cb, state) => response.BeginFlush(cb, state), ar => response.EndFlush(ar), null));
            }

            response.Flush();
            return(TaskAsyncHelper.Empty);
#else
            response.Flush();
            return(TaskAsyncHelper.Empty);
#endif
        }
Beispiel #3
0
        public static Task FlushAsync(this HttpResponseBase response)
        {
            if (!response.IsClientConnected)
            {
                return(TaskAsyncHelper.Empty);
            }
#if NET45
            if (response.SupportsAsyncFlush)
            {
                try
                {
                    return(Task.Factory.FromAsync((cb, state) => response.BeginFlush(cb, state), ar => response.EndFlush(ar), null));
                }
                catch (HttpException ex)
                {
                    // Only swallow http exceptions since we don't want to hide bugs
                    return(TaskAsyncHelper.FromError(ex));
                }
            }
#endif
            try
            {
                response.Flush();
                return(TaskAsyncHelper.Empty);
            }
            catch (HttpException ex)
            {
                // Only swallow http exceptions since we don't want to hide bugs
                return(TaskAsyncHelper.FromError(ex));
            }
        }
 public override void EndFlush(IAsyncResult asyncResult)
 {
     _response.EndFlush(asyncResult);
 }