Ejemplo n.º 1
0
        /// <summary>
        /// EndProcessRequest only does exception handling for this handler.  There is no other information currently sent
        /// back to the file uploader control.
        /// </summary>
        /// <param name="result"></param>
        public void EndProcessRequest(IAsyncResult result)
        {
            UploaderControl2AsyncResult asyncOp = (UploaderControl2AsyncResult)result;

            if (asyncOp.Exception != null)
            {
                asyncOp.Context.Response.Write(asyncOp.Exception.ToString());
            }
        }
Ejemplo n.º 2
0
 public UploaderControl2ProcessFileState(HttpContext context, UploaderControl2AsyncResult result)
 {
     AsyncResult = result;
     Guid        = context.Request.QueryString["guid"];
     FirstChunk  = string.IsNullOrEmpty(context.Request.QueryString["first"]) ? false : bool.Parse(context.Request.QueryString["first"]);
     LastChunk   = string.IsNullOrEmpty(context.Request.QueryString["last"]) ? false : bool.Parse(context.Request.QueryString["last"]);
     Cancel      = string.IsNullOrEmpty(context.Request.QueryString["cancel"]) ? false : bool.Parse(context.Request.QueryString["cancel"]);
     Process     = string.IsNullOrEmpty(context.Request.QueryString["process"]) ? false : bool.Parse(context.Request.QueryString["process"]);
     Name        = context.Request.QueryString["name"];
     UploadedFileProcessorType = context.Request.QueryString["processor"];
     ContextParam = context.Request.QueryString["context"];
 }
Ejemplo n.º 3
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            UploaderControl2AsyncResult result = new UploaderControl2AsyncResult(context, cb, extraData);

            // parse the parameters sent to the request and bundle them up to be passed to the worker thread
            UploaderControl2ProcessFileState processFileState = new UploaderControl2ProcessFileState(context, result);

            // do all of the work on a custom thread pool so that the asp.net thread pool doesn't get blocked up

            // TODO: This example uses the built-in ThreadPool, but you should use a custom thread pool!  The built-in thread pool
            // draws from the same threads that the web server uses to service web requests, so you will see no benefit.
            // See the codeplex project for some links to open source custom thread pool implementations.

            // change this line to queue ProcessFile onto your custom thread pool
            ThreadPool.QueueUserWorkItem(ProcessFile, processFileState);

            return result;
        }
Ejemplo n.º 4
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            UploaderControl2AsyncResult result = new UploaderControl2AsyncResult(context, cb, extraData);

            // parse the parameters sent to the request and bundle them up to be passed to the worker thread
            UploaderControl2ProcessFileState processFileState = new UploaderControl2ProcessFileState(context, result);

            // do all of the work on a custom thread pool so that the asp.net thread pool doesn't get blocked up

            // TODO: This example uses the built-in ThreadPool, but you should use a custom thread pool!  The built-in thread pool
            // draws from the same threads that the web server uses to service web requests, so you will see no benefit.
            // See the codeplex project for some links to open source custom thread pool implementations.

            // change this line to queue ProcessFile onto your custom thread pool
            ThreadPool.QueueUserWorkItem(ProcessFile, processFileState);

            return(result);
        }
Ejemplo n.º 5
0
 public UploaderControl2ProcessFileState(HttpContext context, UploaderControl2AsyncResult result)
 {
     AsyncResult = result;
     Guid = context.Request.QueryString["guid"];
     FirstChunk = string.IsNullOrEmpty(context.Request.QueryString["first"]) ? false : bool.Parse(context.Request.QueryString["first"]);
     LastChunk = string.IsNullOrEmpty(context.Request.QueryString["last"]) ? false : bool.Parse(context.Request.QueryString["last"]);
     Cancel = string.IsNullOrEmpty(context.Request.QueryString["cancel"]) ? false : bool.Parse(context.Request.QueryString["cancel"]);
     Process = string.IsNullOrEmpty(context.Request.QueryString["process"]) ? false : bool.Parse(context.Request.QueryString["process"]);
     Name = context.Request.QueryString["name"];
     UploadedFileProcessorType = context.Request.QueryString["processor"];
     ContextParam = context.Request.QueryString["context"];
 }