1

I'm currently using Red Gate's Performance Profiler to optimize an application. I keep running across a declaration generated by VS and always takes around a second to declare. Its being set to null too. I don't understand why this takes a second to do. I know VS Designer can use this for some components but is there anyway to reduce the number of these declarations? An explanation of why this happens would be great too.

profilerScreenshot

Community
  • 1
  • 1
ExceptionLimeCat
  • 6,191
  • 6
  • 44
  • 77

1 Answers1

1

That is a field initializer. The profiler may be measuring the initialization of the entire class at that line. Try setting the field to null within the constructor instead to see if there is a difference in times.

Peter Ritchie
  • 35,463
  • 9
  • 80
  • 98
  • This line is executed during the initialization of the entire class but it exists in the Designer file and the constructor is the normal class file. Are you saying I should just move this line from the designer to the constructor in the other file? – ExceptionLimeCat Aug 08 '12 at 21:23
  • Move it there only temporarily. If moving it there gives drastically different results, you know it's not *really* taking that much time. – Peter Ritchie Aug 09 '12 at 04:16