DynamoDS/Dynamo — pull request #2429 by Benglin (2014-09-16 09:59:11+00:00)
Title: DO NOT MERGE: Work in progress

Shutdown sequence 1:

1. DynamoView.WindowClosing > RevitDynamoModel.ShutDown
2. RevitDynamoModel.ShutDown > IdlePromise.ExecuteOnShutdown
3. RevitDynamoModel.ShutDown > DynamoModel.ShutDown
4. DynamoModel.ShutDown
5. RevitDynamoModel.ShutDown > IdlePromise.ExecuteOnIdleAsync (PostableCommand.ExitRevit)
6. DynamoRevit.DynamoView_Closing > IdlePromise.ClearPromises
7. DynamoRevit.DynamoView_Closing > IdlePromise.Shutdown
8. DynamoRevit.DynamoView_Closed
9. Shutdown delegate (from Step #2 above)

Shutdown sequence 2:

1. DynamoView.WindowClosing > RevitDynamoModel.ShutDown
2. DynamoRevit.DynamoView_Closing > IdlePromise.ClearPromises
3. DynamoRevit.DynamoView_Closing > IdlePromise.Shutdown
4. DynamoRevit.DynamoView_Closed
5. RevitDynamoModel.ShutDown > IdlePromise.ExecuteOnShutdown
6. RevitDynamoModel.ShutDown > DynamoModel.ShutDown
7. DynamoModel.ShutDown
8. RevitDynamoModel.ShutDown > IdlePromise.ExecuteOnIdleAsync (PostableCommand.ExitRevit)
9. Shutdown delegate NOT executed (#5 comes after #3)

ShutDown sequence 3:

1. DynamoRevit.DynamoView_Closed

There are various ways a shutdown sequence can be initiated:

1. Pressing ```X``` button on Dynamo window (sequence #1)
2. By update manager (sequence #2)
3. File > Exit menu item (sequence #2)
4. Closing Revit main window (sequence #3)