Presentation.BeginUpdate() Method
Locks the Presentation object until the Presentation.EndUpdate method is called.
Namespace: DevExpress.Docs.Presentation
Assembly: DevExpress.Docs.Presentation.v25.1.dll
NuGet Package: DevExpress.Docs.Presentation
Declaration
Remarks
Enclose your code in the BeginUpdate - EndUpdate() method calls to improve performance when you apply multiple modifications to the presentation.
Each call to BeginUpdate must be paired with the EndUpdate() call. You can use the try...finally statement to ensure EndUpdate() is called even if an exception occurs.
The following code snippet use BeginUpdate - EndUpdate() methods:
using DevExpress.Docs.Presentation;
using System.Drawing;
namespace PresentationApiSample;
public class Program {
public static void Main(string[] _) {
// Create a new presentation and clear any default slides
Presentation presentation = new Presentation();
presentation.Slides.Clear();
// Begin a batch update to optimize performance and prevent intermediate presentation updates
presentation.BeginUpdate();
try {
for (int i = 0; i < 5000; i++) {
Slide slide = new Slide(SlideLayoutType.Blank);
presentation.Slides.Add(slide);
slide.Background = new CustomSlideBackground(new SolidFill(new DevExpress.Docs.OfficeColor(Color.LightBlue)));
}
presentation.DocumentProperties.Author = "John Doe";
} finally {
// End the batch update to apply all changes
presentation.EndUpdate();
}
presentation.HeaderFooterManager.AddSlideNumberPlaceholder(presentation.Slides);
presentation.ExportToPdf(new FileStream(@"D:\\exported-document.pdf", FileMode.Create));
}
}
See Also