Application: WorkThread
Revit Platform: All
Revit Version: 2013.0
First Released For: 2013.0
Programming Language: C#
Skill Level: Medium
Category: Basics
Type: ExternalCommand and ExternalApplication

Subject: Sample of a multi-htreaded application utilizing the Idling event
Summary: 
This sample shows how to utilize the Applicaiton.Idling event in order to communicate with the Revit API from an external work thread.

Classes: 
Autodesk.Revit.DB
Autodesk.Revit.UI;
Autodesk.Revit.UI.Selection;
Autodesk.Revit.UI.Events;
Autodesk.Revit.DB.Events;
Autodesk.Revit.DB.Analysis;

Project Files: 
Command.cs
It contains the class Command which inherits from interface IExternalCommand and implements the Execute method.

Application.cs
It contains the class Command which inherits from interface IExternalApplication and implements its methods.

FaceAnalyzer.cs
This class handles displaying results of an analysis of a wall surface.

SharedResults.cs
This class is for exchange of results between the analyzer which displays the results and the work-thread that calculates them. All operations are thread-safe.

ThreadAgent.cs
The main class of the delegated thread which has few data the calculations needs and one method that will run on a separate thread.

Description: 
This sample shows how to utilize the Applicaiton.Idling event in order to communicate with the Revit API from an external work thread.

Instructions: 
1.	Open Revit application and create a new document
2.	Create a simple wall
3.	Go to a 3D view and zoom to see the largest face of the wall
4.	Start the external command - "Analyze Wall Face"
5.	When the command enters a picking mode, click the main face on the wall
6.	You see the analysis starts as the results start appearing on the face
7.	It takes about 12 seconds to complete the process
8.	You can modify the wall or add doors or windows to it during that time
9.	Every time the wall is modified, the analysis starts over (another 12 sec)