Multithreaded raster subset


PurposeThis sample demonstrates using a multithreaded architecture together with ArcObjects to break a lengthy operation (here subsetting a raster layer), into multiple threads so that each thread performs part of the work. The entire task runs in the application background, leaving the application free to perform other tasks.

This sample 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:
1. Spawning a background thread.
2. Working with multiple working threads.
3. Passing task information onto a working thread.
4. Thread synchronization.
5. Waiting for multiple threads to finish their tasks.
6. Updating the application UI from multiple threads while keeping it responsive.

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

How to use

See Using the samples for help on compiling, setting up the debugger, and running the sample (either an exe or dll).

  1. Use VS2005 to compile the project.
  2. Open the customize dialog in either ArcMap or a MapControl application and from the ‘.NET Samples’ category drag ‘Subset Raster MT’ tool onto a toolbar.
  3. Add a raster layer to your application and select the tool.
  4. Use the tool to delineate the area which you’d like to subset.
  5. The tool will open a folder selection dialog. Select an output folder for the output raster and click Open.
  6. Once the subset process starts, you will see a progress dialog showing the progress of the subset done by the different threads.

Additional information

Please note that in order to keep the sample as simple as possible, it does not copy colormap form the input raster to the subset raster should it exist on the input raster. In this case the outcome will be a black and white image.
 
In order to support copying of a colormap see  RasterColorMap example.


SubsetRasterTool.cs Implementation file of the tool that performs the raster subset
frmProgress.cs the application dialog which reports the subset progress
Download the C# files
SubsetRasterTool.vb Implementation file of the tool that performs the raster subset
frmProgress.vb the application dialog which reports the subset progress
Download the VB.NET files

Download the files for all languages

See Also:

Writing Multithreaded ArcObjects Code