DynamicRenderer.GetDispatcher 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回呈现线程的 Dispatcher。
protected:
System::Windows::Threading::Dispatcher ^ GetDispatcher();
protected System.Windows.Threading.Dispatcher GetDispatcher ();
member this.GetDispatcher : unit -> System.Windows.Threading.Dispatcher
Protected Function GetDispatcher () As Dispatcher
返回
呈现线程的 Dispatcher。
示例
以下示例演示如何使用 GetDispatcher 该方法对呈现线程执行一些工作。
delegate void WorkerMethod();
class CustomDynamicRenderer : DynamicRenderer
{
protected override void OnStylusDown(RawStylusInput rawStylusInput)
{
base.OnStylusDown(rawStylusInput);
rawStylusInput.NotifyWhenProcessed(null);
}
protected override void OnStylusDownProcessed(object callbackData, bool targetVerified)
{
base.OnStylusDownProcessed(callbackData, targetVerified);
Dispatcher renderingThreadDispatcher = this.GetDispatcher();
renderingThreadDispatcher.BeginInvoke(DispatcherPriority.Normal, new WorkerMethod(DoSomething));
}
private void DoSomething()
{
// Perform work on the rendering thread.
}
}
Delegate Sub WorkerMethod()
Class CustomDynamicRenderer
Inherits DynamicRenderer
Protected Overrides Sub OnStylusDown(ByVal rawStylusInput As RawStylusInput)
MyBase.OnStylusDown(rawStylusInput)
rawStylusInput.NotifyWhenProcessed(Nothing)
End Sub
Protected Overrides Sub OnStylusDownProcessed(ByVal callbackData As Object, ByVal targetVerified As Boolean)
MyBase.OnStylusDownProcessed(callbackData, targetVerified)
Dim renderingThreadDispatcher As Dispatcher = Me.GetDispatcher()
renderingThreadDispatcher.BeginInvoke(DispatcherPriority.Normal, New WorkerMethod(AddressOf DoSomething))
End Sub
Private Sub DoSomething()
' Perform work on the rendering thread.
End Sub
End Class