public void Page_Load( Object sender, EventArgs e )
    {
        // we have to do all the usual tricks to see any output before the
        // page `renders' completely by asp.net standards.. remember to flush
        for( int i = 0; i < 100; i++ )
        {
            Response.Write( "<span></span>" );
        }

        m_doAsyncDelegate = new DoAsyncDelegate( DoAsync );

        m_asyncTask = new PageAsyncTask(
           new BeginEventHandler( this.BeginLoad ),
           new EndEventHandler( this.EndLoad ),
           null, null, false
        );

        Response.Write("Working");
        Response.Flush();

        // can't be done in the handlers themselves.. have to be before
        // prerender event has fired...
        // AttachHandlers();

        RegisterAsyncTask( m_asyncTask );
    }
	public void Page_Load( Object sender, EventArgs e )
	{
		// we have to do all the usual tricks to see any output before the
		// page `renders' completely by asp.net standards.. remember to flush
		for( int i = 0; i < 100; i++ )
		{
			Response.Write( "<span></span>" );
		}

		m_doAsyncDelegate = new DoAsyncDelegate( DoAsync );

		m_asyncTask = new PageAsyncTask(
	   new BeginEventHandler( this.BeginLoad ),
	   new EndEventHandler( this.EndLoad ),
	   null, null, false
		);
		
		Response.Write("Working");
		Response.Flush();

		// can't be done in the handlers themselves.. have to be before 
		// prerender event has fired...
		// AttachHandlers();
		
		RegisterAsyncTask( m_asyncTask );

		
	}
Esempio n. 3
0
    /**
     * we lay the groundwork for further async calls in page load
     */
    public void Page_Load(Object sender, EventArgs e)
    {
        Response.Write("page load entered\n");

        // we set the timeout to something really long, so that .net
        // won't time out our request - we want long running
        TimeSpan timeOut = new TimeSpan(1, 0, 0, 0, 0);

        this.AsyncTimeout = timeOut;

        // fire up a delegate that invokes the function that we
        // ultimately want to call
        m_doAsyncDelegate = new DoAsyncDelegate(DoAsync);

        // this is a hack to get some browsers to display something
        // we write some data to fill the buffer or something
        for (int i = 0; i < 1000; i++)
        {
            Response.Write("<span></span>");
        }
        Response.Flush();

        // here we set up a periodic poller using threadpool. the
        // basic idea is that we have a call back that is periodically
        // visited by a threadpool thread.  This really isn't a poll,
        // and is not really done by the threadpool, we use an autoresetevent
        m_wtCallback = new WaitOrTimerCallback(Callback);
        AutoResetEvent are = new AutoResetEvent(false);

        ThreadPool.RegisterWaitForSingleObject(are, m_wtCallback, null, 1000, false);

        // the meat of getting this all to work revolves around the
        // registration of handlers for begin and end
        RegisterAsyncTask(
            new PageAsyncTask(
                new BeginEventHandler(this.BeginLoad),
                new EndEventHandler(this.EndLoad),
                null, null, false)
            );
    }
	/**
	 * we lay the groundwork for further async calls in page load
 	 */
	public void Page_Load( Object sender, EventArgs e )
	{
		Response.Write("page load entered\n");

		// we set the timeout to something really long, so that .net
		// won't time out our request - we want long running
		TimeSpan timeOut = new TimeSpan( 1, 0, 0, 0, 0 );
		this.AsyncTimeout = timeOut;
		
		// fire up a delegate that invokes the function that we 
		// ultimately want to call
		m_doAsyncDelegate = new DoAsyncDelegate( DoAsync );
		
		// this is a hack to get some browsers to display something
		// we write some data to fill the buffer or something	
		for( int i=0; i < 1000; i++ )
		{ 
			Response.Write("<span></span>");
		}
		Response.Flush();

		// here we set up a periodic poller using threadpool. the
		// basic idea is that we have a call back that is periodically
		// visited by a threadpool thread.  This really isn't a poll,
		// and is not really done by the threadpool, we use an autoresetevent
		m_wtCallback = new WaitOrTimerCallback( Callback );
		AutoResetEvent are = new AutoResetEvent( false );
		ThreadPool.RegisterWaitForSingleObject( are, m_wtCallback, null, 1000, false );
	
		// the meat of getting this all to work revolves around the 
		// registration of handlers for begin and end
		RegisterAsyncTask( 
			new PageAsyncTask(
	   		new BeginEventHandler( this.BeginLoad ),
	  		new EndEventHandler( this.EndLoad ),
	  		null, null, false )
		);

	}