本文整理汇总了C#中System.Windows.Threading.DispatcherOperation类的典型用法代码示例。如果您正苦于以下问题:C# DispatcherOperation类的具体用法?C# DispatcherOperation怎么用?C# DispatcherOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DispatcherOperation类属于System.Windows.Threading命名空间,在下文中一共展示了DispatcherOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginUpdateLayout
public void BeginUpdateLayout()
{
if (updateLayoutOperation == null || updateLayoutOperation.Status == DispatcherOperationStatus.Completed)
{
updateLayoutOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (Action)UpdateLayout);
}
}
示例2: InvokeParametersTest
public void InvokeParametersTest()
{
int value = 0;
DispatcherOperation operation0 = new DispatcherOperation(() => value = 1);
operation0.Invoke();
Assert.AreEqual(1, value);
}
示例3: Cancel
/// <summary>
/// Cancels a pending DispatcherOperation
/// </summary>
internal void Cancel()
{
if (IsPending)
{
_operation.Abort();
}
_operation = null;
}
示例4: Cancel
internal void Cancel()
{
if (_operation != null)
{
Debug.Assert(_operation.Status == DispatcherOperationStatus.Pending);
_operation.Abort();
_operation = null;
}
}
示例5: Request
internal void Request(object arg)
{
if (_operation == null)
{
Debug.Assert(_callback != null);
_operation =
Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Loaded,
new DispatcherOperationCallback(DispatcherOperation), arg);
}
}
示例6: Request
/// <summary>
/// Requests that a new DispatcherOperation be placed on the Dispatcher queue
/// </summary>
/// <param name="arg">The object to send the callback in its arg parameter.</param>
internal void Request(object arg)
{
if (_operation != null)
{
Cancel();
}
_operation = Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Background,
new DispatcherOperationCallback(DispatcherOperation),
arg);
}
示例7: OnRendering
/// <summary>
/// Called when [rendering].
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnRendering(object sender, EventArgs e)
{
if (this.isDirty)
{
if (this.LowPriorityRendering)
{
// if we called render previously...
if (this.previousRenderCall != null)
{
var previousStatus = this.previousRenderCall.Status;
// ... and the operation didn't finish yet - then skip the current call
if (previousStatus == System.Windows.Threading.DispatcherOperationStatus.Pending
|| previousStatus == System.Windows.Threading.DispatcherOperationStatus.Executing)
{
return;
}
}
this.previousRenderCall = this.Dispatcher.BeginInvoke(this.renderDelegate, System.Windows.Threading.DispatcherPriority.Input);
}
else
{
this.renderDelegate();
}
this.IsDirty = this.AutoRender;
}
}
示例8: OnRendering
/// <summary>
/// Handles the <see cref="CompositionTarget.Rendering"/> event.
/// </summary>
/// <param name="sender">The sender is in fact a the UI <see cref="Dispatcher"/>.</param>
/// <param name="e">Is in fact <see cref="RenderingEventArgs"/>.</param>
private void OnRendering(object sender, EventArgs e)
{
if (!renderTimer.IsRunning)
return;
// Check if there is a deferred updateAndRenderOperation in progress.
if (updateAndRenderOperation != null)
{
// If the deferred updateAndRenderOperation has not yet ended...
var status = updateAndRenderOperation.Status;
if (status == DispatcherOperationStatus.Pending ||
status == DispatcherOperationStatus.Executing)
{
// ... return immediately.
return;
}
updateAndRenderOperation = null;
// Ensure that at least every other cycle is done at DispatcherPriority.Render.
// Uncomment if animation stutters, but no need as far as I can see.
// this.lastRenderingDuration = TimeSpan.Zero;
}
// If rendering took too long last time...
if (lastRenderingDuration > MaxRenderingDuration)
{
// ... enqueue an updateAndRenderAction at DispatcherPriority.Input.
updateAndRenderOperation = Dispatcher.BeginInvoke(
updateAndRenderAction, DispatcherPriority.Input);
}
else
{
UpdateAndRender();
}
}
示例9: BeginInvoke
public DispatcherOperation BeginInvoke (Delegate d, params object[] args)
{
DispatcherOperation op = null;
lock (queuedOperations) {
op = new DispatcherOperation (d, args);
queuedOperations.Enqueue (op);
if (!pending) {
if (callback == null)
callback = new TickCallHandler (dispatcher_callback);
NativeMethods.time_manager_add_dispatcher_call (NativeMethods.surface_get_time_manager (Deployment.Current.Surface.Native),
callback, IntPtr.Zero);
pending = true;
}
}
return op;
}
示例10: DispatcherOperationProxy
/// <summary>
/// Initializes a new instance of the <see cref="DispatcherOperationProxy"/> class.
/// </summary>
/// <param name="operation">The operation.</param>
public DispatcherOperationProxy(DispatcherOperation operation)
{
_operation = operation;
}
示例11: DispatcherOperationEvent
public DispatcherOperationEvent(DispatcherOperation op, TimeSpan timeout)
{
_operation = op;
_timeout = timeout;
_event = new ManualResetEvent(false);
_eventClosed = false;
lock(DispatcherLock)
{
// We will set our event once the operation is completed or aborted.
_operation.Aborted += new EventHandler(OnCompletedOrAborted);
_operation.Completed += new EventHandler(OnCompletedOrAborted);
// Since some other thread is dispatching this operation, it could
// have been dispatched while we were setting up the handlers.
// We check the state again and set the event ourselves if this
// happened.
if(_operation._status != DispatcherOperationStatus.Pending && _operation._status != DispatcherOperationStatus.Executing)
{
_event.Set();
}
}
}
示例12: Initialize
public abstract void Initialize(DispatcherOperation operation);
示例13: Enqueue
public void Enqueue(object userState)
{
if (userState == null)
throw new ArgumentNullException("userState");
CurrentContext = userState as BackgroundActionContext;
if (CurrentContext == null)
throw new NotSupportedException("Not support non BackgroundActionContext type userState");
_latestOperation = UIDispatcher.BeginInvoke(() => DoWork(userState), DispatcherPriority.Background);
}
示例14: TestDispatcherOpOnThread
public void TestDispatcherOpOnThread ()
{
Thread t = new Thread (new ThreadStart (thread));
Dispatcher d = Dispatcher.CurrentDispatcher;
t.Start ();
op = Dispatcher.CurrentDispatcher.BeginInvoke (DispatcherPriority.Normal, (Action) delegate {
Console.WriteLine ("Some methods");
});
wait.Set ();
wait2.WaitOne ();
}
示例15: DPFCanvas
/// <summary>
///
/// </summary>
public DPFCanvas()
{
updateAndRenderAction = UpdateAndRender;
updateAndRenderOperation = null;
renderTimer = new Stopwatch();
MaxRenderingDuration = TimeSpan.FromMilliseconds(20.0);
Loaded += OnLoaded;
Unloaded += OnUnloaded;
ClearColor = global::SharpDX.Color.Gray;
IsShadowMapEnabled = false;
IsMSAAEnabled = true;
}