.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

.NET Matters: Asynchronous Stream Processing

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

This month Stephen Toub discusses asynchronous stream processing.

Stephen Toub

MSDN Magazine March 2008




View Complete Post


More Related Resource Links

.NET Matters: Asynchronous I/O with WebClient

  

In this month's installment of .NET Matters, columnist Stephen Toub answers reader questions concerning asynchronous I/O .

Stephen Toub

MSDN Magazine July 2008


.NET Matters: Stream Pipeline

  

This month Stephen Toub explains how to make the most of dual processors when running encryption and compression tasks.

Stephen Toub

MSDN Magazine February 2008


Making asynchronous calls to web services during ASP.NET page processing

  
Some ASP.NET web applications use web services to get some data that they display to users. Some pages may lay hardly on web services and these pages need some optimization to work better. In this posting I will show you how to use web services behind your ASP.NET page asynchronously and perform a lot of queries to web services. Sample code included! Eneta.Examples.WebAppThreading.zip VS2008 solution | 60KB Asynchronous page processing As an introduction let's see how ASP.NET supports asynchronous calls behind pages. Although we can use our own threading mechanism and avoid what is offered by ASP.NET it is more safe and time saving to use ASP.NET own infrastructure. The image on right that I stole from MSDN article Asynchronous Pages in ASP.NET 2.0 shows you how synchronous and asynchronous pages are processed by ASP.NET. I recommend to read this MSDN article because you can find also other methods for asynchronous calls. I will introduce you how to use PageAsyncTask based calls. If you look at diagram on right you can see that asynchronous processing of registered tasks happens between PreRender and PreRenderComplete events in separate threads. If we have data bound controls on our page we have to move data binding to PreRenderComplete event because this is the closest phase of page processing where asynchronous calls are finished.

Do ASP.NET Crystal Reports support asynchronous processing

  
CR reports take too much of processing time for our web app. I have modified the process to generate reports in the background using ASP.NET asynchronus pages concept. But now, the reports do NOT render at all. This makes me wonder whether they support background processing at all.CR reports take too much of processing time for our web app. I have modified the process to generate reports in the background using ASP.NET asynchronus pages concept.But now, the reports do NOT render at all. This makes me wonder whether they support background processing at all.

Asynchronous ASP.NET Page Processing in Layered Architecture

  

I am working on an application which involves payment gateways. Payment gateway takes some 4-5 seconds to respond. To tune the application I thought of using PageAsyncTask whenever Payments are processed.

My application uses multiple layers, for e.g before hitting to payment gateway, all sorts of calculations(taxes and all) are calculated in bussiness layer and then the payment gateway processing is done in the data access layer. Method which performs the Payments  also returns some custom message to top layers based on the response value. This is done by setting a property in the DAL class.

Now issue is how to register BeginEventHandler and EndEventHandler. I tried creating a sample application for this. But when I debugged my EndEventHandler was not getting called at all.

Sample Scenario..

On a button click event I am trying to call a DAL method which will create a HttpWebRequest and will return the response to me in a string variable

My Page Class has Events below:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
            PageAsyncTask task = new PageAsyncTask(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation),new EndEventHandler(TimeoutAsyncOperation), "" );
            RegisterAsyncTask(task);

Exception during asynchronous processing.

  

I have a pattern like:

          FunctionDelegatge function = new FunctionDelegatge (MyFunction);

          function.BeginInvoke(arg1, arg2, arg3, new AsyncCallback((far) =>

          {

           if (far.IsCompleted)

           {

            lock (resultLock) result.Add(function.EndInvoke(far));

            Interlocked.Decrement(ref orderCount);

           }

          }), null);



Right now every once and a while I get an exception that simply states 'A severe error occured'. In order to track down this error I was wondering if I could get some help in understanding what happens to an exception during asyncronous processing. Specifically what happens if an exception is raised in 'MyFunction' above? How can I safely catch this exception and still have the exception information available for the asynchronous delegate? Ideally I would like to have status something like the BackgroundWorker class where in the process complete method one can test a property to see if an error occurred. Also what if arg1 etc. was a SqlConnection that if the connection is terminated (this is within a WCF web service)

Asynchronous ASP.NET Page Processing(PageAsyncTask) in Layered Architecture

  

I am working on an application which involves payment gateways. Payment gateway takes some 4-5 seconds to respond. To tune the application I thought of using PageAsyncTask whenever Payments are processed.

My application uses multiple layers, for e.g before hitting to payment gateway, all sorts of calculations(taxes and all) are calculated in bussiness layer and then the payment gateway processing is done in the data access layer. Method which performs the Payments  also returns some custom message to top layers based on the response value. This is done by setting a property in the DAL class.

Now issue is how to register BeginEventHandler and EndEventHandler. I tried creating a sample application for this. But when I debugged my EndEventHandler was not getting called at all.

Sample Scenario..

On a button click event I am trying to call a DAL method which will create a HttpWebRequest and will return the response to me in a string variable

My Page Class has Events below:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
            PageAsyncTask task = new PageAsyncTask(new BeginEventHandler(BeginAsyncOperation), new EndEventHandler(EndAsyncOperation),new EndEventHandler(TimeoutAsyncOperation), "" );
            RegisterAsyncTask(t

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

  
Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

jQuery live() and ASP.NET Ajax asynchronous postback

  
The issue is that normally $(document).ready() is called when the DOM is ready to be manipulated. But this doens't happen after an ASP.NET Ajax asynch postback occurs.

This means that the initial jQuery bindings won't be automatically available after the asynchronous postback is over. I underline "automatically" here because my last post describes more possibilities, how this issue can be worked around.

how to impose javascript event processing?

  

If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?

Thanks


Image processing, determine white space and crop

  

Hi,


I have created a image upload for our ID card system to allow users to upload new images, edit them and submit for approval.  This is all working well with a combination of asp.net (c#) and jquery to give a seemless editor etc.

We have had a few users who I cannot believe have scanned a photo of themself and then just submitted it with the A4 page of white and little photo.


I am wondering if anyone can help with a suggestion on how I could possibly reduce the load of these coming through (I can't believe they can be this stupid), it stipulates UK passport standards.


Would my only option be to check for a single continues colour that occurs and if it reaches a certain percentage point say 60% then to just send back an error stating they need to crop the image.

Can anyone help with providing sample or that I can use to move this one on.


I am still in disbelief on this one.  the other one is they take a photo of whole body and other in it and cut straight down middle chopping the people out but supplying a photo that no use for an id photo card....but that I can't imagine being solved programatically as I need to determine where their face dimensions are and what percentage of the actual photo is taken up by it and if it below a threshold reject it.




Easy image processing(grayscale, sepia, negative, resize, brightness, contrast and opacity)

  
Howdie y'all,

I see a lot of questions in this forum about resizing images. Recently I created a code sample(with downloadable webapp), right here.

The class (downloaded or created) allows for very fast and easy processing of your images. And a lot of problems over here can be solved by simply using that class. I thought it might help to mention the code sample in this forum as well.

Cheers,

Wes

Cutting Edge: Revisiting Asynchronous ASP.NET Pages

  

If you need to scale up an existing Web application, you should first look to asynchronous operations, says Dino Esposito. He explains how new features coming in ASP.NET MVC 2 make this easier.

Dino Esposito

MSDN Magazine April 2010


.NET Matters: Aggregating Exceptions

  

Exceptions in .NET are the fundamental mechanism by which errors and other exceptional conditions are communicated. This month's column provides information about how to aggregate exceptions to help manage a variety of scenarios in which multiple exceptions might result from one operation, including scenarios involving parallelism and concurrency.

Stephen Toub

MSDN Magazine August 2009


Peer Fun: A Peer-To-Peer Work Processing App With WCF

  

We demonstrate creating a peer-to-peer processing platform where multiple players function together for a common purpose: getting your work done.

Matt Neely

MSDN Magazine June 2009


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend