Doc.SuspendsUpdate() has a warning of “shouldn’t be using”. When I am adding a bunch of things to a document, that I don’t want to cause to relayout (until the end) what is the right way to stop laying out until the end?
If you’re doing something like a Layout in GoDocument.Changed, add your own flag for suspending that activity, then do the Layout when you clear that flag.
Not sure that is what I am doing… So I have a “builder” that builds a specific document. Each of the “Add(node)” seems to be kicking off a layout. I need to be able to do all of the “Adds” and then kick off one layout. So I am not sure if your answer applies. If it does, then you need to explain further.
I think Jake is just saying that wherever your code is doing a layout (or any other potentially computationally-intensive operation) you could put in a check for some flag, and not do the layout when the flag is true.
Then when you want to do a bunch of Add’s, you can first set the flag, and afterwards clear it and explicitly do the layout or other operation.
GoPalette.AutomaticLayout is exactly such a flag, predefined for use when initializing the palette’s GoDocument. (Well, I guess the sense of the flag is inverted from what I said above.)
But SuspendsUpdate() is not the way to go?
That’s correct – don’t use any of the Suspends… properties unless you really know what you are doing.