DrawJob Class
Represents an asynchronous drawing job.
Inheritance Hierarchy
SystemObject
  TallComponents.PDF.RasterizerDrawJob

Namespace:  TallComponents.PDF.Rasterizer
Assembly:  TallComponents.PDF.Rasterizer (in TallComponents.PDF.Rasterizer.dll) Version: 3.0.158.0
Syntax
public class DrawJob : IDisposable

The DrawJob type exposes the following members.

Constructors
  NameDescription
Public methodDrawJob
Create a new asynchronous drawing job for the given page.
Top
Properties
  NameDescription
Public propertyJobStatus
The job status.
Public propertySummary
The summary of the current drawing job.
Top
Methods
  NameDescription
Public methodDispose
Stops, and Disposes the draw job. The job may not stop immediately, but at a moment that permits it.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetBitmap
Get a copy of the bitmap for as far as it has been drawn. This may return null, e.g. when the job has not yet been started, or after calling Dispose for the job.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStart
Start drawing the page to the given bitmap.
Public methodStop
Stop drawing. The job may not stop immediately, but at a moment that permits it.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWait
Wait until the job has stopped, or is ready.
Top
Events
  NameDescription
Public eventUpdated
Raised regularly while the job is running and immediately after drawing has finished. This event is provided as a convenience so that the generated bitmap can be inspected regularly, without needing to implement this functionality oneself. As a rule of thumb, this event gets fired at a higher frequency for simple drawing jobs, so that results can be shown quickly, and at a lower frequency for complex jobs, so that the drawing job itself will not be slowed down too much by frequent updates.
Top
Remarks
Examples

The code below shows one way to use a DrawJob. Instead of simply calling Page.Draw(), one can create a DrawJob, start it, and then do some additional work before obtaining the drawn bitmap.

drawJob = new DrawJob(page);

Bitmap mybitmap = new Bitmap(
   ( int ) ( page.Width / 72 * dpi ),
   ( int ) ( page.Height / 72 * dpi ) );

float scale = ( float ) ( dpi / 72F );

Matrix transformation = new Matrix();
transformation.Scale( scale, scale );

drawJob.Start(mybitmap, renderSettings, PageBoundary.Default, transformation);

// ...Drawing will start on a separate thread. In the meantine, one could do
// some additional work here.

// Wait until drawing has finished.
drawJob.Wait();

// Obtain a copy of the bitmap that has been drawn.
System.Drawing.Bitmap bitmap = drawJob.GetBitmap();

One will typically use a DrawJob to render a page progesssively. After a drawing job has been started, it is possible to obtain intermediate bitmap results by calling DrawJob.GetImage() while the job is running. This can be done at arbitrary moments, for example via a timer.

An easier way is to subscribe to the Updated event of the DrawJob and retrieve a new bitmap in the event handler. The Updated event will be fired regularly, but it will only be fired when the bitmap has actually been updated. After finishing the drawing job, the Updated event will be raised one last time.

drawJob = new DrawJob(page);
drawJob.Updated += new EventHandler(drawJob_Updated);

...
drawJob.Start(...);

...

void drawJob_Updated(object sender, EventArgs e)
{
  // Obtain a copy of the bitmap for as far as it has been drawn.
  System.Drawing.Bitmap bitmap = drawJob.GetBitmap();

  ...
}
See Also