title: VSTO add-in for MS Project: display tasks all at once
body: <p>The code below (in standard ThisAddIn class of a VSTO add-in) retrieves info about tasks to be added to MS Project (2013) and then adds actual tasks to project Tasks collection. The problem is the Project allowing to add tasks one by one and repainting (refreshing) the project view every time a task is added to Tasks collection. It looks annoying. So far I found and used <em>Application.ScreenUpdating</em> property to hide the blinking.</p>
  
  <p>It would be nice to prepare a collection of tasks and attach them <em>all together</em> to the active project. Could anyone more experienced please point towards a way to accomplish this? If it's possible at all with the current MS Project Add-In API?</p>
  
  <p>Thanks a lot.</p>
  
  <pre><code>....
  using MSProject = Microsoft.Office.Interop.MSProject;
  ....
  
  public partial class ThisAddIn
  {
      ....
  
      private void ShowTasks()
      {
          MSProject.Project project = this.Application.ActiveProject;
          // TaskInfo is a custom DTO type
          IEnumerable&lt;TaskInfo&gt; dataSource = GetDataSourceSomehow();
  
          this.Application.ScreenUpdating = false;
          this.Application.Calculation = MSProject.PjCalculation.pjManual;
  
          foreach(TaskInfo info in dataSource)
          {
              MSProject.Task task = project.Tasks.Add(info.TaskName);
          }
  
          this.Application.ScreenUpdating = true;
      }
  }
  </code></pre>