How to improve the performance of task dependency creation in a VSTO add-in when processing more than 2000 tasks RRS feed

  • Question

  • Hi,

    We are trying to create 2000 tasks from a XML input and setting around 20 attributes for each task.

    This process is taking around 4-5 minutes.

    Then, we are trying to create the dependencies between tasks in the same process.

    We are using the below code to create dependency.



          succTask.TaskDependencies.Add(predTask, linkType);

    If the dependencies is volume is more, ex:- 1000), it is taking 10 more minutes.

    We tried to optimize the code using the below settings.

                            Application.ScreenUpdating = false;
                            Application.DisplayStatusBar = false;
                            Application.DisplayAlerts = false;
                            Application.Calculation = MSProject.PjCalculation.pjManual;


                            Application.Calculation = MSProject.PjCalculation.pjAutomatic;
                            Application.DisplayAlerts = true;
                            Application.DisplayStatusBar = true;
                            Application.ScreenUpdating = true;

    This actually reduced the dependency creation from 10 minutes to 6 minutes. But still it is not acceptable to the customer.

    Are we following right approach to create dependencies?

    Are they any other settings that we can disable/enable to improve the performance?



    Thursday, March 10, 2016 1:16 PM

All replies

  • I think using the TaskDependencies object could be slowing you down. Even though Automatic Calculation is turned off, Project still does some calculation when fields change. I don't do bulk addition of relationships but I do have functions that manipulate them using the activity's Successors property. You could try building the Successors strings in code and then assigning them as you iterate through the tasks. That way, more of your work involves string manipulation and you're only making one assignment per task instead of making one assignment per relationship (given that each task is involved in more than one relationship). If you have UniqueIDs you can use the UniqueIDSuccessors field.You should also ungroup and remove filters if those exist.

    I have a feeling that six minutes for 1000 relationships might be as good as it gets with VSTO (Rod is going to tell you that VBA will be faster).

    Thursday, March 10, 2016 3:02 PM
  • Guess what. VBA is faster! The reason is that VSTO runs in a separate process whilst VBA runs within the Project process. So every VSTO action is an inter-process one (think slow).

    You could try building the predecessor string to a Text field then at the end copying the text data to the Predecessors column. That might be faster.

    Rod Gill
    Author of the one and only Project VBA Book

    Friday, March 11, 2016 4:31 AM