Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » Ajax » General » Downloads
 

HTTP Push from SQL Server — Comet SQL

By , 27 Nov 2012
 
// Copyright (c) 2010 Daniel Wojciechowski 
// E-mail: at gmail.com daniel.wojciechowski

using System;
using System.Threading;
using System.Web;

namespace HttpPushFromMsSql
{
    public class CometAsyncResult:IAsyncResult
    {
        private bool isCompleted = false;
        private bool completedSynchronously = false;

        /// <summary> Some information about situation on client
        /// side. Last seen record ID. This is example parameter
        /// for clarification what are we waiting for. </summary>
        public int LastRecId;


        public DateTime StartTime;
        public TimeSpan WaitTime;

        /// <summary> Callback that will be called when operation is completed
        /// (When we have notification about hanges, or timeout)</summary>
        public AsyncCallback Callback;

        public HttpContext Context;
        /// <summary> True when there is notification, False if timeout </summary>
        public bool Result;
 
        /// <summary>
        /// Default constructor. Can be used when request completed
        /// synchronously. In this case must set CompletedSynchronously 
        /// to true.
        /// </summary>
        public CometAsyncResult()
        {
        }

        public CometAsyncResult(HttpContext context, AsyncCallback asyncCallback, int waitTime, int lastRecId)
        {
            Context = context;
            Callback = asyncCallback;
            StartTime = DateTime.Now;
            WaitTime = new TimeSpan(0, 0, waitTime);
            LastRecId = lastRecId; 
        }

        public bool IsCompleted
        {
            get { return isCompleted; }
            set { isCompleted = value; }
        }
        public bool CompletedSynchronously
        {
            get { return completedSynchronously; }
            set { completedSynchronously = value; }
        }

        private readonly WaitHandle asyncWaitHandle = null;
        public WaitHandle AsyncWaitHandle { get { return asyncWaitHandle; } }

        private readonly object asyncState=null;
        public object AsyncState { get { return asyncState; } }

    }
}

By viewing downloads associated with this article you agree to the Terms of use 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.

License

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

About the Author

CoperNick
Software Developer
Poland Poland
Member
I graduated from the Jagiellonian University (and yes — I'm proud of this — and it was sometimes hard for me). After defence of master thesis (link to presentation) I have started professional programming in C and C++ using OpenGL. After that, my Company gave me a chance to switch to .Net framework and C# and I have betrayed my passion for computer graphics. Now I'm pure and happy C#, SQL and sometimes ASP.NET programmer.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 27 Nov 2012
Article Copyright 2010 by CoperNick
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid