XmlStreamStore.Flush 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
强制将内部缓冲区中保留的所有批注数据写入基础存储设备中。
public:
override void Flush();
public override void Flush ();
override this.Flush : unit -> unit
Public Overrides Sub Flush ()
例外
已在存储区上调用 Dispose。
还没有为存储区设置 I/O Stream。
存储区 I/O Stream 为只读,且无法进行输出访问。
示例
下面的示例演示如何在应用程序关闭AnnotationService时使用Flush该方法。
// -------------------------- 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
以下示例演示了 DeleteAnnotation 如何使用和 Flush 方法。
// ------------------------- 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();
}