Sofia, Bulgaria | 9-10 October Asynchronous Programming for ASP.NET 2.0 Developers Julie Lerman The Data Farm Julie Lerman The Data Farm.

Slides:



Advertisements
Similar presentations
Best Practices on ASP.NET AJAX Bill Xie Jan 30, CSU Fullerton SoCal Code Camp.
Advertisements

SQL Server 2005 Query Notifications
Sofia, Bulgaria | 9-10 October Developing An Advanced ASP.NET Server Control With Rich Design-Time Goksin Bakir Yage Ltd Microsoft Regional Director, MEA.
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Module 1: Creating Responsive Pages with Ajax Creating Partial-Page Updates by Using AJAX Scripting Actions on the Web Client.
Advanced Performance Techniques in ASP.NET 2.0 William Zhang, Ph.D. Senior Consultant Microsoft Consulting Services.
ASP.NET 2.0: Advanced Server Controls and Web Parts with ASP.NET 2.0 Sam Spencer Program Manager Web Platform and Tools Microsoft DEV414.
ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
WCF RIA Services - Querying and Updating Data SILVERLIGHTSHOW.NET WEBINARS SERIES BRIAN NOYES, CHIEF ARCHITECT, IDESIGN INC 2 FEB 2011.
Microsoft ASP.NET AJAX - AJAX as it has to be Presented by : Rana Vijayasimha Nalla CSCE Grad Student.
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
XML Web Services in Visual Studio.NET Peter Ty Developer Evangelist.NET and Developer Group.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
AJAX in ASP.NET James Crowley Developer Fusion
Sofia, Bulgaria | 9-10 October Large-Scale Client Script Development in ASP.NET "Atlas“ Tools, Tips, And Techniques Hristo Deshev telerik Hristo Deshev.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Spicing Up Web Parts Randy Williams SharePoint Hawaii User Group May 11, 2011.
AJAX and Atlas in ASP.NET 2.0 William J. Steele MSDN Developer Evangelist Microsoft Corporation
Node.js - What is Node.js? -
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
CSCI 6962: Server-side Design and Programming AJAX Tools in JSF and ASP.
Sofia, Bulgaria | 9-10 October Advanced Data Access Patterns with ADO.NET 2.0 Julie Lerman The Data Farm Julie Lerman The Data Farm.
Ventsislav Popov Crossroad Ltd.. 1. What is AJAX?  AJAX Concept  ASP.NET AJAX Framework 2. ASP.NET AJAX Server Controls  ScriptManager, UpdatePanel.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Database Handling, Sessions, and AJAX. Post Back ASP.NET Functionality The IsPostBack method in ASP.NET is similar to the BlackBerry.refresh method –IsPostBack.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
ADVANCED WEB SERVICES. Three Advanced Web Service Techniques SOAP Extensions Asynchronous calls Custom wire formatting SOAP Extensions Asynchronous calls.
Developing AJAX Web applications with Castle Monorail David De Florinier Gojko Adzic Skills Matter 12/06/08.
Real-World AJAX Seminar - March 13, 2006 Bringing the Richness and Responsiveness of Desktop Applications to the Web Sahil Malik telerik.
Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.
WEB428 ASP.NET 2.0: Advanced Server Controls and Web Parts with ASP.NET 2.0 Andres Sanabria Program Manager Web Platform and Tools Team Microsoft Corporation.
RUBRIC IP1 Ruben Botero Web Design III. The different approaches to accessing data in a database through client-side scripting languages. – On the client.
Quick overview of ASP.NET Ajax Ajax deep-dive Cover some key real-world problems Discuss solutions, patterns, opportunities Lots of demos And more of.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Ajax VS Flex A comparison based on shopping cart implementation PoHsu Yeh py2157.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
PostBack  When an initial request for a page (a Web Form) is received by ASP.NET, it locates and loads the requested Web Form (and if necessary compiles.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
ASP.Net ICallback Vijayalakshmi G M Senior Trainer Binary Spectrum.
ASP.net Course From Intermediate to Advance level By Arsalan Ahmed 3 Months Course Cell :
Wes Preston DEV 202. Audience: Info Workers, Dev A deeper dive into use-cases where client-side rendering (CSR) and SharePoint’s JS Link property can.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Building rich web applications with ASP.NET AJAX Mike Ormond Developer & Platform Evangelism Group, Microsoft Ltd Developer & Platform Evangelism Group,
DAT303 - Entity Framework: Application Patterns Pablo Castro Technical Lead, Microsoft Corporation.
Working with Client-Side Scripting
AJAX.
Jim Fawcett CSE686 – Internet Programming Summer 2008
Creating Windows Store Apps Using Visual Basic
Anatomy of an ASP.NET Page
Introduction to jQuery
ASP.NET 4.0 State Management Improvements – Deep Dive
Running C# in the browser
Presentation transcript:

Sofia, Bulgaria | 9-10 October Asynchronous Programming for ASP.NET 2.0 Developers Julie Lerman The Data Farm Julie Lerman The Data Farm

Sofia, Bulgaria | 9-10 October About Me ●.NET Mentor and Software Consultant ●20+ years developing ●Microsoft.NET MVP, ASPInsider ●INETA Speaker ●Various publications & conferences ●Blogs: thedatafarm.com/blog, blog.ziffdavis.com/devlife ●Founder and leader of Vermont.NET ●Former INETA Board Member ●INETA Speaker Committee ●Vermont Software Developer Alliance Board ●.NET Mentor and Software Consultant ●20+ years developing ●Microsoft.NET MVP, ASPInsider ●INETA Speaker ●Various publications & conferences ●Blogs: thedatafarm.com/blog, blog.ziffdavis.com/devlife ●Founder and leader of Vermont.NET ●Former INETA Board Member ●INETA Speaker Committee ●Vermont Software Developer Alliance Board

Sofia, Bulgaria | 9-10 October Overview ●Asynchronous Patterns in.NET ●New ASP.NET 2.0 Features ●Asynchronous Pages ●Asynchronous Web Services ●Asynchronous Tasks ●Asynchronous Data Access ●Client Side Callbacks ATLAS ●Post-Cache Substitution ●Asynchronous Patterns in.NET ●New ASP.NET 2.0 Features ●Asynchronous Pages ●Asynchronous Web Services ●Asynchronous Tasks ●Asynchronous Data Access ●Client Side Callbacks ATLAS ●Post-Cache Substitution

Sofia, Bulgaria | 9-10 October Asynchronous Patterns in.NET ●Pre-.NET 2.0 ●Delegates & Callbacks ●IAsyncResult ●WaitHandle ●.NET 2.0 Event Based Async Pattern ●Plumbing is hidden ●Still need IAsyncResult in a few cases ●Implemented throughout.NET ●In WinForms, In ASP.NET, In ADO.NET ●Pre-.NET 2.0 ●Delegates & Callbacks ●IAsyncResult ●WaitHandle ●.NET 2.0 Event Based Async Pattern ●Plumbing is hidden ●Still need IAsyncResult in a few cases ●Implemented throughout.NET ●In WinForms, In ASP.NET, In ADO.NET

Sofia, Bulgaria | 9-10 October Asynchronous Methods ●When calling out to external processes ●Use classes that can do so asynchronously ●Class must have ●Begin_Method(callback,state) as IAsyncResult ●End_Method(IAsyncResult) ●When calling out to external processes ●Use classes that can do so asynchronously ●Class must have ●Begin_Method(callback,state) as IAsyncResult ●End_Method(IAsyncResult) Hello World WS Proxy class BeginHelloWorld EndHelloWorld

Sofia, Bulgaria | 9-10 October Thread B Async Event Pattern Application Process Do long running process Sub MethodthatCallsLRP End Sub Sub LRPCompleted_Event_Handler End Sub Thread A Call BeginLRP Do other stuff EndLRP(IAsyncResult) Do stuff with results sent back Do other stuff External Process (or separate thread in app process)

Sofia, Bulgaria | 9-10 October Synchronous Pages Application Thread Pool One thread pool per process Default 25 threads per pool Change with SetMaxThreads ? ? ? ?

Sofia, Bulgaria | 9-10 October Asynchronous Pages ●Purpose: Handle more requests ●Free up threads when external processes are called 1.Begin page rendering 2.Drop thread while async process is running Thread is now available to other requests 3.Grab new thread when process completes 4.Finish rendering ●Purpose: Handle more requests ●Free up threads when external processes are called 1.Begin page rendering 2.Drop thread while async process is running Thread is now available to other requests 3.Grab new thread when process completes 4.Finish rendering

Sofia, Bulgaria | 9-10 October Coding Async Pages ●Client Side ● ●Server Side ●Page.AddOnPreRenderCompleteAsync (new BeginEventHandler(MyBeginMethod), new EndEventHandler (MyEndMethod) ) ●Client Side ● ●Server Side ●Page.AddOnPreRenderCompleteAsync (new BeginEventHandler(MyBeginMethod), new EndEventHandler (MyEndMethod) )

Sofia, Bulgaria | 9-10 October Demonstration Asynchronous Pages

Sofia, Bulgaria | 9-10 October Async Web Services ●IAsyncResult pattern (.NET 1.x & 2.0) ●ws.BeginmyMethod / ws.EndmyMethod ●Manually manage context information ●Coordination ●Use waitHandle to postpone page rendering ●Can be combined with Asynchronous Pages ●Event Based Asynchronous Pattern (NET 2.0) ●ws.myMethodAsync / ws.myMethodCompleted ●HttpContext, Impersonation & culture carry ●Coordination ●Render automatically continues when all services complete ●IAsyncResult pattern (.NET 1.x & 2.0) ●ws.BeginmyMethod / ws.EndmyMethod ●Manually manage context information ●Coordination ●Use waitHandle to postpone page rendering ●Can be combined with Asynchronous Pages ●Event Based Asynchronous Pattern (NET 2.0) ●ws.myMethodAsync / ws.myMethodCompleted ●HttpContext, Impersonation & culture carry ●Coordination ●Render automatically continues when all services complete

Sofia, Bulgaria | 9-10 October Demonstration Asynchronous Web Services

Sofia, Bulgaria | 9-10 October Asynchronous Tasks ●(Page) AddOnPreRenderCompleteAsync ●Limited to one asynchronous call ●Asynchronous Tasks ●Make multiple (non web service) async calls ●Timeout setting ●Completion of multiple tasks is coordinated ●Code ● PageAsyncTask + RegisterAsyncTask ● ●Per task ●Defaults at 45 seconds ●(Page) AddOnPreRenderCompleteAsync ●Limited to one asynchronous call ●Asynchronous Tasks ●Make multiple (non web service) async calls ●Timeout setting ●Completion of multiple tasks is coordinated ●Code ● PageAsyncTask + RegisterAsyncTask ● ●Per task ●Defaults at 45 seconds

Sofia, Bulgaria | 9-10 October Demonstration Asynchronous Tasks

Sofia, Bulgaria | 9-10 October Async Data Binding ●SqlCommand’s new async commands ●BeginExecuteReader/EndExecuteReader ●Begin ExecuteXmlReader/EndExecuteXmlReader ●Begin ExecuteNonQuery/EndExecuteNonQuery ●Call a BeginExecute in MyBeginMethod ●Call an EndExecute in MyEndMethod ●Returns an IAsyncResult ●Cast result back to data object ●DataBind in PreRenderComplete ●“Asynchronous Processing=True” in connection string ●SqlCommand’s new async commands ●BeginExecuteReader/EndExecuteReader ●Begin ExecuteXmlReader/EndExecuteXmlReader ●Begin ExecuteNonQuery/EndExecuteNonQuery ●Call a BeginExecute in MyBeginMethod ●Call an EndExecute in MyEndMethod ●Returns an IAsyncResult ●Cast result back to data object ●DataBind in PreRenderComplete ●“Asynchronous Processing=True” in connection string

Sofia, Bulgaria | 9-10 October Begin/End Execute ●Variety of overloads including callbacks, object state and command behavior ●Must call corresponding End to finish ●End will block SqlCommand until execution completes ●Use separate SqlCommand objects for each asynchronous call ●Variety of overloads including callbacks, object state and command behavior ●Must call corresponding End to finish ●End will block SqlCommand until execution completes ●Use separate SqlCommand objects for each asynchronous call

Sofia, Bulgaria | 9-10 October Demonstration Asynchronous Data Binding

Sofia, Bulgaria | 9-10 October Client-Side Callbacks ●Enables partial page postbacks ●Update controls from server ●Created before AJAX and ATLAS ●Complicated and hard to use ●Recommend AJAX or ATLAS instead ●Enables partial page postbacks ●Update controls from server ●Created before AJAX and ATLAS ●Complicated and hard to use ●Recommend AJAX or ATLAS instead

Sofia, Bulgaria | 9-10 October Client-Side Callbacks ●Calls server side process to update single web server control on a page ●Page does not post back ●Wired up in the code behind ●GetCallBackEventReference ●Ties server method, client script and control ●Four Overloads ●Calls server side process to update single web server control on a page ●Page does not post back ●Wired up in the code behind ●GetCallBackEventReference ●Ties server method, client script and control ●Four Overloads

Sofia, Bulgaria | 9-10 October Client-Side Callbacks ●Avoid using viewstate on affected control ●Browser basics ●Internet Explorer 5+ ●Uses Microsoft.XMLHttp ●Other Browsers ●Uses XMLHttpRequest of the browser’s DOM ●Great for simple scenarios ●AJAX &Atlas for more complex use ●Avoid using viewstate on affected control ●Browser basics ●Internet Explorer 5+ ●Uses Microsoft.XMLHttp ●Other Browsers ●Uses XMLHttpRequest of the browser’s DOM ●Great for simple scenarios ●AJAX &Atlas for more complex use

Sofia, Bulgaria | 9-10 October Client Side Callback Puzzle Pieces [2] Create New Data Function Implements RaiseCallbackEvent [3] Return Data to Client Function Implements GetCallbackResult [5] RegisterClientScriptBlock script that wires things up on the client side Server Side (code behind) [4] GetCallbackEventReference wire up page, display script, functions and affected control Client Side Control (if web server control, avoid ViewState) Display Update Script update control’s display upon callback Trigger calls script [5] registered from the server side [1] Implement ICallbackEventHandler in code or declaratively

Sofia, Bulgaria | 9-10 October Demonstration Partial Page Postback with ATLAS

Sofia, Bulgaria | 9-10 October Post-Cache Substitution ●Update pieces page when rest of page is cached ● control ●Property: MethodName=“myStaticMethod” ●Static method returns a string to control ●Response.WriteSubstitution(....) ●Can be embedded in html ●Can be used elsewhere in code ●Static methods not required when outside page ●Controls are updated after cached page is rendered ●Update pieces page when rest of page is cached ● control ●Property: MethodName=“myStaticMethod” ●Static method returns a string to control ●Response.WriteSubstitution(....) ●Can be embedded in html ●Can be used elsewhere in code ●Static methods not required when outside page ●Controls are updated after cached page is rendered

Sofia, Bulgaria | 9-10 October Demonstration Post-Cache Substitution

Sofia, Bulgaria | 9-10 October Summary ●Build more efficient & responsive web apps with async ASP.NET 2.0 ●Free up threads in the thread pool while page is pre-rendering ●Run multiple processes concurrently to speed up pre-rendering ●Leverage caching when only a bit of the page needs to be changed at postback ●Modify page parts without a full post- back ●Build more efficient & responsive web apps with async ASP.NET 2.0 ●Free up threads in the thread pool while page is pre-rendering ●Run multiple processes concurrently to speed up pre-rendering ●Leverage caching when only a bit of the page needs to be changed at postback ●Modify page parts without a full post- back

Sofia, Bulgaria | 9-10 October Thank You! ●Contact Info Julia Lerman The Data Farm ●Blog ● ●Contact Info Julia Lerman The Data Farm ●Blog ●

Sofia, Bulgaria | 9-10 October Further Reading ●Asynchronous Pages in ASP.NET 2.0, Jeff Prosise, MSDN Magazine Oct 2005 ●Five Undiscovered Features on ASP.NET 2.0, Jeff Prosise Feb 2005 ●Calling Web Services Asynchronously, Dan Wahlin, asp.netPRO, July 2006 ●Fritz Onion Weblog: pluralsight.com/blogs/fritz ●Asynchronous Web Parts, Fritz Onion, MSDN Mag July 2006 ●MSDN VS2005 Docs: “Threads & Threading” ●Asynchronous Command Execution in ADO.NET 2.0, Pablo Castro, Microsoft : us/dnvs05/html/async2.asp ●Asynchronous Pages in ASP.NET 2.0, Jeff Prosise, MSDN Magazine Oct 2005 ●Five Undiscovered Features on ASP.NET 2.0, Jeff Prosise Feb 2005 ●Calling Web Services Asynchronously, Dan Wahlin, asp.netPRO, July 2006 ●Fritz Onion Weblog: pluralsight.com/blogs/fritz ●Asynchronous Web Parts, Fritz Onion, MSDN Mag July 2006 ●MSDN VS2005 Docs: “Threads & Threading” ●Asynchronous Command Execution in ADO.NET 2.0, Pablo Castro, Microsoft : us/dnvs05/html/async2.asp

Sofia, Bulgaria | 9-10 October Please fill out the survey forms! They are the key to amazing prizes that you can get at the end of each day Thank you!

Sofia, Bulgaria | 9-10 October