XmlStreamStore.Flush Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Forces any annotation data retained in internal buffers to be written to the underlying storage device.
public:
override void Flush();
public override void Flush ();
override this.Flush : unit -> unit
Public Overrides Sub Flush ()
Exceptions
Dispose has been called on the store.
An I/O Stream has not been set for the store.
The store I/O Stream is read-only and cannot be accessed for output.
Examples
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()
' -------------------------- StopAnnotations -------------------------
''' <summary>
''' Disables annotations processing and hides annotations.</summary>
Public Sub StopAnnotations()
' If the AnnotationStore is active, flush and close it.
If (_annotService IsNot Nothing) AndAlso _annotService.IsEnabled Then
_annotService.Store.Flush()
_annotStream.Flush()
_annotStream.Close()
End If
' If the AnnotationService is active, shut it down.
If _annotService IsNot Nothing Then
If _annotService.IsEnabled Then
_annotService.Disable()
End If
_annotService = Nothing
End If
End Sub
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();
}
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET