Common Timer redraw


Purpose
This sample demonstrates how to leverage a timer in the browser client to automate asynchronous requests that update page content for a given time interval. In this sample, graphics are updated in the Map control. The automated asynchronous requests to the server are managed by the PostbackManager control.
 
This sample provides the following examples:
  • SimpleUpdate.aspx—Illustrates automatic updating of feature and element graphics. Update logic is executed on the same thread that handles the page request.
  • ThreadedUpdate.aspx—Illustrates automatic updating of graphics where the update logic is dispatched to a new thread. For long running operations, this allows a response to be returned quickly to the client so the Web application remains responsive.
For more information on the PostbackManager control, see the Sample: Common PostbackManager topic.

How to use

If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. Verify that the Web Application Developer Framework (ADF) for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit10.0\Samples\ServerNET. This folder contains the Common_TimerRedraw CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_TimerRedraw_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
  5. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site, expand Default Web Site, right-click the Common_TimerRedraw_<language> folder, and click Properties. The Properties dialog box opens.
  6. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  7. Start Microsoft Visual Studio, and open the solution for the version of Visual Studio you're using. The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file for the Common_TimerRedraw_CSharp sample is Common_TimerRedraw_CSharp2008.sln and is located in the c:\inetpub\wwwroot\Common_TimerRedraw_CSharp folder.
  8. In Solution Explorer, right-click the page you want to view and select Set As Start Page.
  9. Open the same page in Design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens.
  10. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, or ArcWeb). In some of the sample code, it is assumed that the resource is in a geographic coordinate system.
  11. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to step 14.
  12. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer and selecting the Add ArcGIS Identity option. Enter the identity credentials that will be used to access ArcGIS Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is checked, the identity tag is encrypted; otherwise the username and password are stored as clear text.
  13. Open the web.config file, add an <identity> element to <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. If you're working with ArcGIS Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
  14. Save the project.
  15. Click the Debug drop-down menu and click Start Debugging.

At run time
  1. Browse to the viewer uniform resource locator (URL) (for example, http://localhost/Common_TimerRedraw_CSharp).
  2. On either page, click the button below the map to start the timer that automates drawing graphics in the map.
  3. Alter the draw interval (in seconds) to change the frequency of redraws.

Common_TimerRedraw_CSharp\SimpleUpdate.aspx Code to manage async requests from the client. The response references the updated graphic content.
Common_TimerRedraw_CSharp\SimpleUpdate.aspx.cs Code to create and update graphics layers.
Common_TimerRedraw_CSharp\ThreadedUpdate.aspx Code to manage async request groups from the client. The first request initiates the graphic draw on the server and notifies the client that an update is pending. Subsequent requests in the group check the status of graphics being drawn; if complete, graphic content is returned to the client.
Common_TimerRedraw_CSharp\ThreadedUpdate.aspx.cs Code to create and update graphics layers in different threads.
Download the C# files
Common_TimerRedraw_VBNet\SimpleUpdate.aspx Code to manage async requests from the client. The response references the updated graphic content.
Common_TimerRedraw_VBNet\SimpleUpdate.aspx.vb Code to create and update graphics layers.
Common_TimerRedraw_VBNet\ThreadedUpdate.aspx Code to manage async request groups from the client. The first request initiates the graphic draw on the server and notifies the client that an update is pending. Subsequent requests in the group check the status of graphics being drawn; if complete, graphic content is returned to the client.
Common_TimerRedraw_VBNet\ThreadedUpdate.aspx.vb Code to create and update graphics layers in different threads.
Download the VB.NET files

Download the files for all languages

See Also:

Sample: PostbackManager control