Damian,
GenerateGrid API is a static method that we don't design to allow user abort the processing.
I provide the source of this method, I think you can easy to apply abort function at for loop.
public static void GenerateGrid(GridDefinition gridDefinition, GridInterpolationModel gridInterpolationModel, Stream outputStream)
{
GridCell[,] cells = GenerateGridMatrix(gridDefinition, gridInterpolationModel);
int columnNumber = Convert.ToInt32(Math.Ceiling(Math.Round((gridDefinition.GridExtent.LowerRightPoint.X - gridDefinition.GridExtent.UpperLeftPoint.X) / gridDefinition.CellSize, 8)));
int rowNumber = Convert.ToInt32(Math.Ceiling(Math.Round((gridDefinition.GridExtent.UpperLeftPoint.Y - gridDefinition.GridExtent.LowerRightPoint.Y) / gridDefinition.CellSize, 8)));
using (StreamWriter streamWriter = new StreamWriter(outputStream))
{
streamWriter.WriteLine("ncols {0}", columnNumber);
//Write nrows
streamWriter.WriteLine("nrows {0}", rowNumber);
//Write xllcorner
streamWriter.WriteLine("xllcorner {0}", gridDefinition.GridExtent.UpperLeftPoint.X);
//Write yllcorner
streamWriter.WriteLine("yllcorner {0}", gridDefinition.GridExtent.LowerRightPoint.Y);
//Write cellsize
streamWriter.WriteLine("cellsize {0}", gridDefinition.CellSize);
//Write NODATA_Value
streamWriter.WriteLine("NODATA_Value {0}", gridDefinition.NoDataValue);
for (int row = 0; row < rowNumber; row++)
{
for (int col = 0; col < columnNumber; col++)
{
if (col != columnNumber - 1)
{
streamWriter.Write(string.Format("{0} ", cells[row, col].Value));
}
else
streamWriter.Write(cells[row, col].Value);
}
streamWriter.WriteLine();
}
streamWriter.Flush();
}
}
Thanks,
James