Multithreaded MapCruncher


Purpose
This sample creates a console application that uses a map document, target scale, folder path, and cache name to create a cache of maps.
 
This sample demonstrates how to use the MapCooker class to generate a cache of an existing map document. This cache can then be added to a map document as a raster. Developers can leverage the MapCooker to rasterize base maps for use in disconnected and dynamic display applications.
 
The sample also demonstrates using a multithreaded architecture together with ArcObjects to break a lengthy operation into multiple threads so that each thread performs a part of the work. It follows the programming pattern of the Threads in Isolation model, which means that cross-thread communication is reduced to an absolute minimum and is done with only simple types. The issues covered by this sample are as follows:
  • Generating a background thread
  • Working with multiple working threads
  • Passing task information onto a working thread
  • Thread synchronization
  • Waiting for multiple threads to finish tasks
  • Updating the application user interface (UI) from multiple threads while keeping it responsive

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. 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.

  1. Start Visual Studio, build the solution, and compile the project.
  2. Open a command prompt and navigate to the compiled executable.
  3. Execute the MapCruncherConsole application from the command line. For example type in MapCruncherConsole.exe "C:\MyDocument\MyDocument.mxd" 24,000 "C:\CacheFolder" "MyDocumentCache"
  4. Once the cache is finished processing, open Engine or Desktop, navigate to the cache folder, and add the cache as a raster.

MapCruncherConsole\MapCruncherClass.cs MapCruncher class. Uses the MapCooker to create a cache.
MapCruncherConsole\Program.cs Console application that consumes the MapCruncher class.
Download the C# files

Download the files for all languages

See Also:

Writing multithreaded ArcObjects code




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcInfo ArcInfo
ArcEditor ArcEditor
ArcView ArcView