AnnotationStore.Flush Method

Forces any annotation data retained in internal buffers to be written to the underlying storage device.

Namespace:  System.Windows.Annotations.Storage
Assembly:  PresentationFramework (in PresentationFramework.dll)

public abstract void Flush()

ExceptionCondition
ObjectDisposedException

Dispose has been called on the store.

Applications that use an explicit-save model can set AutoFlush to false and call Flush directly when appropriate.

Applications that use an implicit-save model can set the AutoFlush to true to cause Flush to be called automatically after every store operation (add, delete, or modify).

The following example shows how to use the Flush method when the application closes the AnnotationService.

// -------------------------- StopAnnotations ------------------------- 
/// <summary> 
///   Disables annotations processing and hides annotations.</summary> 
public void StopAnnotations()
{
    // If the AnnotationStore is active, flush and close it. 
    if ( (_annotService != null) && _annotService.IsEnabled )
    {
        _annotService.Store.Flush();
        _annotStream.Flush();
        _annotStream.Close();
    }

    // If the AnnotationService is active, shut it down. 
    if (_annotService != null)
    {
        if (_annotService.IsEnabled)
            _annotService.Disable();
        _annotService = null;
    }
}// end:StopAnnotations()

The following example shows use of the DeleteAnnotation and Flush methods.

// ------------------------- DeleteMark_Click ------------------------- 
void DeleteMark_Click(object sender, RoutedEventArgs e)
{
    Annotation ann = ((MenuItem)sender).Tag as Annotation;
    _annStore.DeleteAnnotation(ann.Id);
    _annStore.Flush();

    MenuItem thisMenu = sender as MenuItem;
    ContextMenu parentMenu = thisMenu.Parent as ContextMenu;
    FrameworkElement dObj =
        parentMenu.PlacementTarget as FrameworkElement;
    while (!(dObj is StackPanel))
    {
        dObj = dObj.Parent as FrameworkElement;
    }

    ListBox collection = dObj.Parent as ListBox;
    collection.Items.Remove(dObj);
    Util.FlushDispatcher();
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft