本文整理汇总了C#中System.Windows.Threading.DispatcherOperation类的典型用法代码示例。如果您正苦于以下问题:C# DispatcherOperation类的具体用法?C# DispatcherOperation怎么用?C# DispatcherOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DispatcherOperation类属于System.Windows.Threading命名空间,在下文中一共展示了DispatcherOperation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BeginUpdateLayout
public void BeginUpdateLayout()
{
if (updateLayoutOperation == null || updateLayoutOperation.Status == DispatcherOperationStatus.Completed)
{
updateLayoutOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (Action)UpdateLayout);
}
}
开发者ID:highzion,项目名称:Granular,代码行数:7,代码来源:LayoutManager.cs
示例2: InvokeParametersTest
public void InvokeParametersTest()
{
int value = 0;
DispatcherOperation operation0 = new DispatcherOperation(() => value = 1);
operation0.Invoke();
Assert.AreEqual(1, value);
}
开发者ID:highzion,项目名称:Granular,代码行数:8,代码来源:DispatcherOperationTest.cs
示例3: Cancel
/// <summary>
/// Cancels a pending DispatcherOperation
/// </summary>
internal void Cancel()
{
if (IsPending)
{
_operation.Abort();
}
_operation = null;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:DeferredRequest.cs
示例4: Cancel
internal void Cancel()
{
if (_operation != null)
{
Debug.Assert(_operation.Status == DispatcherOperationStatus.Pending);
_operation.Abort();
_operation = null;
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:DeferredRequest.cs
示例5: Request
internal void Request(object arg)
{
if (_operation == null)
{
Debug.Assert(_callback != null);
_operation =
Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Loaded,
new DispatcherOperationCallback(DispatcherOperation), arg);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:DeferredRequest.cs
示例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);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:DeferredRequest.cs
示例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;
}
}
开发者ID:vmsr42,项目名称:AncientHorror,代码行数:34,代码来源:WaveCanvas.cs
示例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();
}
}
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:41,代码来源:DPFCanvas.cs
示例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;
}
开发者ID:kangaroo,项目名称:moon,代码行数:16,代码来源:Dispatcher.cs
示例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;
}
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:8,代码来源:DispatcherOperationProxy.cs
示例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();
}
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:23,代码来源:DispatcherOperation.cs
示例12: Initialize
public abstract void Initialize(DispatcherOperation operation);
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:1,代码来源:DispatcherOperationTaskSource.cs
示例13: DispatcherOperation
private object DispatcherOperation(object arg)
{
try
{
Debug.Assert(_operation != null && _operation.Status == DispatcherOperationStatus.Executing);
_callback(arg);
}
finally
{
_operation = null;
}
return null;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:DeferredRequest.cs
示例14: DispatcherOperationFrame
// Note: we pass "exitWhenRequested=false" to the base
// DispatcherFrame construsctor because we do not want to exit
// this frame if the dispatcher is shutting down. This is
// because we may need to invoke operations during the shutdown process.
public DispatcherOperationFrame(DispatcherOperation op, TimeSpan timeout) : base(false)
{
_operation = op;
// We will exit this frame once the operation is completed or aborted.
_operation.Aborted += new EventHandler(OnCompletedOrAborted);
_operation.Completed += new EventHandler(OnCompletedOrAborted);
// We will exit the frame if the operation is not completed within
// the requested timeout.
if(timeout.TotalMilliseconds > 0)
{
_waitTimer = new Timer(new TimerCallback(OnTimeout),
null,
timeout,
TimeSpan.FromMilliseconds(-1));
}
// Some other thread could have aborted the operation while we were
// setting up the handlers. We check the state again and mark the
// frame as "should not continue" if this happened.
if(_operation._status != DispatcherOperationStatus.Pending)
{
Exit();
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:31,代码来源:DispatcherOperation.cs
示例15: DispatcherOperationAsyncResult
public DispatcherOperationAsyncResult(DispatcherOperation operation)
{
operation.ThrowIfNull("operation");
this._AsyncWaitHandle = new Lazy<WaitHandle>(this.AsyncWaitHandleFactory);
this.Operation = operation;
}
开发者ID:catwalkagogo,项目名称:Heron,代码行数:6,代码来源:DispatcherSynchronizeInvoke.cs
示例16: Parse
/// <summary>
/// Parses the current document content
/// </summary>
public void Parse()
{
IsParsing = true;
string code = "";
Dispatcher.Invoke(new Action(() => code = Editor.Text));
GC.Collect();
DModule newAst = null;
//try {
SyntaxTree = null;
using (var sr = new StringReader(code))
using (var parser = DParser.Create(sr))
{
var sw = new Stopwatch();
code = null;
sw.Restart();
newAst = parser.Parse();
sw.Stop();
SyntaxTree = newAst;
ParseTime = sw.Elapsed.TotalMilliseconds;
}
/*}
catch (Exception ex)
{
ErrorLogger.Log(ex, ErrorType.Warning, ErrorOrigin.Parser);
}*/
lastSelectedBlock = null;
lastSelectedStatement = null;
if (newAst != null)
{
newAst.FileName = AbsoluteFilePath;
newAst.ModuleName = ProposedModuleName;
}
//TODO: Make semantic highlighting 1) faster and 2) redraw symbols immediately
UpdateSemanticHighlighting(true);
//CanRefreshSemanticHighlightings = false;
UpdateTypeLookupData();
if (postParseOperation != null && postParseOperation.Status != DispatcherOperationStatus.Completed)
postParseOperation.Abort();
postParseOperation = Dispatcher.BeginInvoke(new Action(() =>
{
try
{
if (GlobalProperties.Instance.ShowSpeedInfo)
CoreManager.Instance.MainWindow.SecondLeftStatusText =
Math.Round((decimal)ParseTime, 3).ToString() + "ms (Parsing duration)";
UpdateFoldings();
CoreManager.ErrorManagement.RefreshErrorList();
RefreshErrorHighlightings();
}
catch (Exception ex) { ErrorLogger.Log(ex, ErrorType.Warning, ErrorOrigin.System); }
}), DispatcherPriority.ApplicationIdle);
IsParsing = false;
}
开发者ID:ephe-meral,项目名称:D-IDE,代码行数:69,代码来源:DEditorDocument.cs
示例17: BeginInvoke
public DispatcherOperation BeginInvoke (Delegate d, params object[] args)
{
DispatcherOperation op = null;
if (Deployment.IsShuttingDown) {
/* DRT #232: some object calls us from the dtor, which happens to run upon shutdown. Here we access
* Deployment::Current::Surface, which may have been destroyed if we're shutting down (and accessing
* it again will recreate it, which is very bad). So just bail out if this is the case. */
return new DispatcherOperation (null, null); // return a dummy object
}
lock (queuedOperations) {
op = new DispatcherOperation (d, args);
queuedOperations.Enqueue (op);
if (time_manager == IntPtr.Zero) {
if (callback == null)
callback = new TickCallHandler (dispatcher_callback);
time_manager = NativeMethods.surface_get_time_manager_reffed (Deployment.Current.Surface.Native);
NativeMethods.time_manager_add_dispatcher_call (time_manager, callback, IntPtr.Zero);
}
}
return op;
}
开发者ID:snorp,项目名称:moon,代码行数:23,代码来源:Dispatcher.cs
示例18: work
private void work()
{
while (!m_disposed) {
bool getInput = false;
using (m_lockHelper.GetLock()) {
if (m_disposed) {
continue;
}
else if (m_workWaiting) {
getInput = true;
m_workWaiting = false;
}
else {
m_lockHelper.Wait();
continue;
}
}
if (getInput && !m_disposed) {
m_operation = Dispatcher.BeginInvoke(DispatcherPriority.Background, m_preWork);
if (!m_disposed && m_operation.Wait() == DispatcherOperationStatus.Completed) {
bool processInput = (bool)m_operation.Result;
m_operation = null;
if (processInput) {
bool workSucceeded = false;
try {
m_work();
workSucceeded = true;
}
catch (Exception ex) {
if (Util.IsCriticalException(ex)) {
throw;
}
else {
OnClientException(new NotifyWorkerClientExceptionEventArgs(ex));
}
}
if (!m_disposed && workSucceeded) {
// Aside from just calling m_postWork,
// we want to call OnClientException with null to clear
// out a LastException, if one exists...all on the Dispatcher thread
m_operation = Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(delegate() {
m_postWork();
OnClientException(null);
}));
if (!m_disposed) {
m_operation.Wait();
}
m_operation = null;
} // if (!m_disposed && workSucceeded)
} // if (processInput && !m_disposed)
} // if Operation completed
} // if (getInput)
} // while (!m_disposed)
}
开发者ID:edealbag,项目名称:bot,代码行数:68,代码来源:NotifyWorker.cs
示例19: DispatcherOperationTaskMapping
public DispatcherOperationTaskMapping(DispatcherOperation operation)
{
Operation = operation;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:DispatcherOperationTaskMapping.cs
示例20: 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);
}
开发者ID:Mrding,项目名称:Ribbon,代码行数:11,代码来源:UIThreadTask.cs
注:本文中的System.Windows.Threading.DispatcherOperation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论