DynamoDS/Dynamo — pull request #2276 by Benglin (2014-09-01 04:09:05+00:00)
Title: Integrated "DynamoScheduler" into "DynamoModel" (disabled by default)

Background
-----
This pull request continues the scheduler work established in [a previous pull request](https://github.com/DynamoDS/Dynamo/pull/2202) by integrating ```DynamoScheduler``` as part of the ```DynamoModel```. ```DynamoScheduler``` can be enabled by using a preprocessor ```ENABLE_DYNAMO_SCHEDULER``` for both ```DynamoCore``` and ```DynamoRevit``` projects.

Changes
-----
New code is confined within ```ENABLE_DYNAMO_SCHEDULER``` preprocessor, and is currently disabled.

1. The following new public APIs are added to ```DynamoScheduler``` class:

```cs
DynamoScheduler(ISchedulerThread schedulerThread);
void Shutdown();
void ScheduleForExecution(AsyncTask asyncTask);
```

2. Shutdown sequence of ```DynamoSchedulerThread``` has been simplified to do without an ```AutoResetEvent```.

3. ```DynamoModel.RunExpression``` method now schedules a ```UpdateGraphAsyncTask``` instead of calling ```DynamoRunner.RunExpression```.

4. ```UpdateGraphAsyncTask``` is made to call back into ```DynamoModel.OnUpdateGraphCompleted``` (in the context of ```ISchedulerThread```) to gather build/runtime warnings (for display on ```NodeView``` through binding).

5. ```RevitDynamoModel.Start``` now instantiate a ```RevitSchedulerThread``` before passing it down to ```DynamoModel``` constructor (so ```DynamoModel``` uses this scheduler thread instead of the default one).

6. Test cases are updated to work with the new scheduler signature.

Known Issues
-----
1. Graphs with custom nodes will not work as of this pull request, as the [```CompileCustomNodeAsyncTask``` class](https://github.com/Benglin/Dynamo/blob/Concurrent/src/DynamoCore/Core/Threading/CompileCustomNodeAsyncTask.cs) still resides on [Concurrent branch](https://github.com/Benglin/Dynamo/tree/Concurrent).

2. Notifications are not currently sent out to the listeners of ```DynamoModel.OnEvaluationCompleted``` event. This causes preview bubbles and background geometries to be not generated (but the computation and actual geometries are generated internally). This will be hooked up in a subsequent pull request.

Note to Reviewers
-----
Hi guys (@aparajit-pratap, @sharadkjaiswal), the previous one you were reviewing (#2250) was closed due to messed up merge issues, forget about that one and use this one instead.

This PR is a continuation of the scheduler work from [previous pull requests](https://github.com/DynamoDS/Dynamo/pull/2202). It is a subset of what have gone into the ```Concurrent``` [branch](https://github.com/Benglin/Dynamo/compare/Concurrent), just to make reviewers' life easier.

![Image of the Octodex]
(https://octodex.github.com/images/collabocats.jpg)