当前位置: 首页>>代码示例>>C#>>正文


C# ContextCallback类代码示例

本文整理汇总了C#中ContextCallback的典型用法代码示例。如果您正苦于以下问题:C# ContextCallback类的具体用法?C# ContextCallback怎么用?C# ContextCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContextCallback类属于命名空间,在下文中一共展示了ContextCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run(CompressedStack compressedStack, ContextCallback callback, object state)
        {
            if (compressedStack == null)
            {
                throw new ArgumentNullException(nameof(compressedStack));
            }

            // The original code was not checking for a null callback and would throw NullReferenceException
            callback(state);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:CompressedStack.cs

示例2: GetPostActionCallback

 private static ContextCallback GetPostActionCallback()
 {
     var callback = _postActionCallback;
     if (callback == null)
     {
         // lazily initialize SecurityCritical delegate
         _postActionCallback = callback = PostAction;
     }
     return callback;
 }
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:10,代码来源:SynchronizationContextAwaitTaskContinuation.cs

示例3: PartialTrustInvoke

 internal static void PartialTrustInvoke(ContextCallback callback, object state)
 {
     if (NeedPartialTrustInvoke)
     {
         SecurityContext.Run(aspNetSecurityContext.CreateCopy(), callback, state);
     }
     else
     {
         callback(state);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:AspNetPartialTrustHelpers.cs

示例4: ExecuteCallback

 internal void ExecuteCallback()
 {
     if (TargetExecutionContext != null)
     {
         var callback = s_executionContextCallback;
         if (callback == null)
             s_executionContextCallback = callback = new ContextCallback(CancellationCallbackInfo.ExecutionContextCallback);
         ExecutionContext.Run(this.TargetExecutionContext, callback, this);
     }
     else
         ExecutionContextCallback(this);
 }
开发者ID:BclEx,项目名称:BclEx-Extend,代码行数:12,代码来源:CancellationCallbackInfo.cs

示例5: Run

 /// <summary>
 /// Runs a method in a specified execution context on the current thread.
 /// </summary>
 public static void Run(ExecutionContext context, ContextCallback callback, object state)
 {
     var syncContext = SynchronizationContext.Current;
     try
     {
         SynchronizationContext.SetSynchronizationContext(context.m_synchronizationContext);
         callback(state);
     }
     finally
     {
         SynchronizationContext.SetSynchronizationContext(syncContext);
     }
 }
开发者ID:ddunkin,项目名称:PortableContrib,代码行数:16,代码来源:ExecutionContext.cs

示例6: Enqueue

 /// <summary>
 /// The Enqueue method is invoked to add a callback action
 /// to the sequencer's queue of operations.
 /// </summary>
 /// <param name="callback">
 /// The callback that is to be invoked.
 /// </param>
 /// <param name="state">
 /// The state information to be passed to the callback
 /// method when it is executed.
 /// </param>
 public void Enqueue(ContextCallback callback, object state)
 {
     SequencedTask task = new SequencedTask(callback, state, ExecutionContext.Capture());
     lock (_taskQueue)
     {
         _taskQueue.Enqueue(task);
         if (_pending == false)
         {
             _pending = true;
             ThreadPool.UnsafeQueueUserWorkItem(Execute, null);
         }
     }
 }
开发者ID:recurry,项目名称:VersaFix,代码行数:24,代码来源:VfxSequencer.cs

示例7: ExecuteCallback

 internal void ExecuteCallback()
 {
     if (this.TargetExecutionContext != null)
     {
         ContextCallback contextCallback = CancellationCallbackInfo.s_executionContextCallback;
         if (contextCallback == null)
         {
             contextCallback = (CancellationCallbackInfo.s_executionContextCallback = new ContextCallback(CancellationCallbackInfo.ExecutionContextCallback));
         }
         ExecutionContext.Run(this.TargetExecutionContext, contextCallback, this);
         return;
     }
     CancellationCallbackInfo.ExecutionContextCallback(this);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:14,代码来源:CancellationCallbackInfo.cs

示例8: Run

        public static void Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        {
            ExecutionContextSwitcher ecsw = default(ExecutionContextSwitcher);
            try
            {
                EstablishCopyOnWriteScope(ref ecsw);

                ExecutionContext.Restore(executionContext);
                callback(state);
            }
            catch
            {
                // Note: we have a "catch" rather than a "finally" because we want
                // to stop the first pass of EH here.  That way we can restore the previous
                // context before any of our callers' EH filters run.  That means we need to 
                // end the scope separately in the non-exceptional case below.
                ecsw.Undo();
                throw;
            }
            ecsw.Undo();
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:21,代码来源:ExecutionContext.cs

示例9: QueueUserWorkItem

 /// <summary>
 /// Queues a work item for processing on the managed thread pool
 /// </summary>
 /// <param name="callback">A WaitCallback representing the method to execute.</param>
 /// <param name="ctx">Alternate execution context in which to run the thread.</param>
 /// <returns>Reference to queued thread</returns>
 /// <remarks>
 /// This differs from the normal thread pool QueueUserWorkItem function in that it does
 /// not return a success value determing if item was queued, but rather a reference to
 /// to the managed thread that was actually placed on the queue.
 /// </remarks>
 public static ManagedThread QueueUserWorkItem(ContextCallback callback, ExecutionContext ctx)
 {
     return QueueUserWorkItem(callback, null, ctx);
 }
开发者ID:avs009,项目名称:gsf,代码行数:15,代码来源:ManagedThreadPool.cs

示例10: Run

		public static void Run (ExecutionContext executionContext, ContextCallback callback, object state)
		{
			if (executionContext == null) {
				throw new InvalidOperationException (Locale.GetText (
					"Null ExecutionContext"));
			}

			// FIXME: supporting more than one context should be done with executionContextSwitcher
			// and will requires a rewrite of this method
			var callContextCallBack = new ContextCallback (new Action<object> ((ostate) => {
				var originalCallContext = CallContext.CreateLogicalCallContext (true);
				try {
					CallContext.SetCurrentCallContext (executionContext.LogicalCallContext);
					callback (ostate);
				} finally {
					CallContext.SetCurrentCallContext (originalCallContext);
				}
			}));
			SecurityContext.Run (executionContext.SecurityContext, callContextCallBack, state);
		}
开发者ID:ramonsmits,项目名称:mono,代码行数:20,代码来源:ExecutionContext.cs

示例11: ManagedThread

 /// <summary>
 /// Initializes a new instance of the ManagedThread class, specifying a delegate that allows an object to be passed to the thread when the thread is started
 /// and allowing the user to specify an alternate execution context for the thread.
 /// </summary>
 public ManagedThread(ContextCallback callback, ExecutionContext ctx)
     : this(ThreadType.StandardThread, callback, null, ctx)
 {
     m_thread = new Thread(HandleItem);
 }
开发者ID:avs009,项目名称:gsf,代码行数:9,代码来源:ManagedThread.cs

示例12: CallbackEntry

 public CallbackEntry(int number, int range, ContextCallback callback)
     : base(number, range)
 {
     m_Callback = callback;
 }
开发者ID:brodock,项目名称:genova-project,代码行数:5,代码来源:PlayerMobile.cs

示例13: ExecutionContextRunData

 internal ExecutionContextRunData(ExecutionContext executionContext, ContextCallback cb, Object state)
 {
     this.ec = executionContext;
     this.callBack = cb;
     this.state = state;
     ecsw = new ExecutionContextSwitcher();
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:7,代码来源:executioncontext.cs

示例14: Run

        public static void Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        {
            if (executionContext == null)
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext"));

            Thread currentThread = Thread.CurrentThread;
            ExecutionContextSwitcher ecsw = default(ExecutionContextSwitcher);
            try
            {
                EstablishCopyOnWriteScope(currentThread, ref ecsw);
                ExecutionContext.Restore(currentThread, executionContext);
                callback(state);
            }
            catch
            {
                // Note: we have a "catch" rather than a "finally" because we want
                // to stop the first pass of EH here.  That way we can restore the previous
                // context before any of our callers' EH filters run.  That means we need to 
                // end the scope separately in the non-exceptional case below.
                ecsw.Undo(currentThread);
                throw;
            }
            ecsw.Undo(currentThread);
        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:24,代码来源:ExecutionContext.cs

示例15: CallCallback

 internal void CallCallback()
 {
     // call directly if EC flow is suppressed
     if (m_executionContext == null)
     {
         m_timerCallback(m_state);
     }
     else
     {
         using (ExecutionContext executionContext = 
             m_executionContext.IsPreAllocatedDefault ? m_executionContext : m_executionContext.CreateCopy())
         {
             ContextCallback callback = s_callCallbackInContext;
             if (callback == null)
                 s_callCallbackInContext = callback = new ContextCallback(CallCallbackInContext);
             
             ExecutionContext.Run(
                 executionContext,
                 callback,
                 this,  // state
                 true); // ignoreSyncCtx
         }
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:24,代码来源:Timer.cs


注:本文中的ContextCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。