Asynchronous encoding

The WPFEncode application demonstrates how to encode a file from a UI application when displaying the progress of the encoding process. To use the application, click the Browse button to point to a file that you want to encode and then click the Encode button to encode it. When the file is encoding, a bar displays the encoding progress.

When you press the Encode button, the application creates a thread to perform the encode to make sure that the UI thread is not blocked. The progress events are called from a non-UI thread. Consequently, we use the Windows Presentation Foundation Dispatcher to marshal the updates to the UI thread.

If you try to close the application when the encoding is still occurring, the application prompts you to confirm that you want to stop the process. If you confirm, the application stops the encoding thread but delays closing the application until the thread actually stops.

See also

Other resources

Expression Encoder 2 SDK