none
Project 2010: Performance problems with "Resource.MaterialLabel" RRS feed

  • Question

  • Hello.

    I start a Project 2010 Add In solution from scratch in VS 2013.

    Then I add the following lines to "NewProject" event handler

    void Application_NewProject(MSProject.Project pj)
    {
        long begin = DateTime.Now.Ticks;
    
        for (int i = 0; i < 1000; i++)
        {
            MSProject.Resource res = pj.Resources.Add("Resource" + i.ToString());
            res.Type = MSProject.PjResourceTypes.pjResourceTypeMaterial;
            res.Code = "Unit" + i.ToString();
            //res.MaterialLabel = "Unit" + i.ToString();
        }
    
        TimeSpan elapsed = new TimeSpan(DateTime.Now.Ticks - begin);
        Debug.WriteLine("Elapsed: " + elapsed.TotalSeconds);
    }
    

    This code runs smoothly and takes about 3.5 seconds in my computer

    Now, comment the line that assigns the code (res.Code = (...)) and uncomment the one assigning MaterialLabel.

    When I run again, CPU usage goes to 100% (all 4 proccesors busy), many other Windows apps starts flickering (Excel 2010 among them) and the code takes about 50 seconds to run.

    I think"Material Label" property is just a string, showing information about the units you measure your resources with, but clearly it's doing something else...

    What?

    Thursday, June 26, 2014 11:33 PM

All replies

  • Hi,

    Thank you for posting in the MSDN Forum.

    Since the issue is more relate to the project, I'd like to move it to Project Customization and Programming forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, June 27, 2014 6:43 AM
  • Do you have SP2 installed for project 2010? If not, try it.

    Yes .MaterialLabel is a text string and the following code works as expected in Project VBA:

    Sub Test()
    Dim Res As Resource
        Set Res = ActiveProject.Resources.Add(Name:="Resource1")
        Res.Type = pjResourceTypeMaterial
        Res.MaterialLabel = "Unit1"
    End Sub

    Unfortunately I have noticed inconsistencies between VSTO and VBA and it's possible that this is one of those problems if SP2 does not fix the problem.


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Friday, June 27, 2014 10:53 PM
    Moderator
  • Hello.

    Yes, SP2 is already installed.

    The problem is not that the code doesn't do what it should. After the long wait, with all the flickering, and 100% CPU usage, the output is as expected.

    Using any other text field, the program behaves normally.

    I've also tried the same code in VBA with the same results

    Sub Macro1()
    ' Macro Macro1
    
        For Count = 1 To 1000
            Dim Res As Resource
            Set Res = ActiveProject.Resources.Add(Name:="Resource" + Str(Count))
            Res.Type = pjResourceTypeMaterial
            Res.SetField pjResourceText1, "Unit" + Str(Count)
            'Res.MaterialLabel = "Unit" + Str(Count)
        Next Count
        
    End Sub

    Of course, the table is showing "Text1" field
    Friday, June 27, 2014 11:40 PM
  • Project 2010 SP2 took 2.5 seconds to run in a new file on Win7 64 bit 8GB memory. CPU usage peaked at 60% but quickly went back down.

    So not sure what's happening for you. Can you try on a different PC? What version windows and how much memory do you have?


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Sunday, June 29, 2014 12:28 AM
    Moderator
  • Zamorano,

    Just for reference I ran your code on a new Project 2010 file with no initial resources. The first run took about 8 secs, the second run took 16 seconds and the third run took 24 seconds. Then I deleted all 3000 resources and made another run. The runtime was again 8 seconds. Not sure why but that seems to indicate the runtime is related to the number of resources already present in the file.

    I run Project 2010 Pro (32 bit) with SP2 on an virtual PC (i.e. Parallels) running Windows 7.

    John


    Sunday, June 29, 2014 4:17 PM
  • The configuration of my laptop is as follows: Intel Core i5, 8 GB RAM, Win 8.1 Pro x64, Office 2010 x64, Visual Studio 2013 Update 2, VSTO Updated May 2014

    Speaking of VSTO, the problem happens on both Debug and Release configurations.

    I have also access to another Win7 machine on a VMWare. I'll give it a try and keep informing.



    Monday, June 30, 2014 2:29 PM