C# 调用线程并行上下文穿透-ILogicalThreadAffinative+CallContext
na mespace System.Runtime.Remoting.Messaging
{
/// <summary>Provides a set of properties that are carried with the execution code path. This class cannot be inherited.</summary>
// Token: 0x0200085D RID: 2141
[SecurityCritical]
[ComVisible(true)]
[Serializable]
public sealed class CallContext /// <summary>Stores a given object and associates it with the specified name.</summary>
/// <param name="name">The name with which to associate the new item in the call context. </param>
/// <param name="data">The object to store in the call context. </param>
/// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception>
// Token: 0x06005B36 RID: 23350 RVA: 0x0013EAFC File Offset: 0x0013CCFC
[SecurityCritical]
public static void SetData(string name, object data)
{
if (data is ILogicalThreadAffinative)
{
CallContext.LogicalSetData(name, data);
return;
}
ExecutionContext mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext();
mutableExecutionContext.LogicalCallContext.FreeNamedDataSlot(name);
mutableExecutionContext.IllogicalCallContext.SetData(name, data);
} /// <summary>Stores a given object in the logical call context and associates it with the specified name.</summary>
/// <param name="name">The name with which to associate the new item in the logical call context. </param>
/// <param name="data">The object to store in the logical call context, this object must be serializable. </param>
/// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception>
// Token: 0x06005B37 RID: 23351 RVA: 0x0013EB40 File Offset: 0x0013CD40
[SecurityCritical]
public static void LogicalSetData(string name, object data)
{
ExecutionContext mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext();
mutableExecutionContext.IllogicalCallContext.FreeNamedDataSlot(name);
mutableExecutionContext.LogicalCallContext.SetData(name, data);
}
C# 调用线程并行上下文穿透-ILogicalThreadAffinative+CallContext的更多相关文章
- C#线程 并行线程
第五部分 并行线程 在本节中,我们将介绍Framework 4.0新增的利用多核处理器的多线程API: 并行LINQ或PLINQ Parallel 类 任务并行性构造 并发集合 自旋锁和自旋等待 ...
- 《GPU高性能编程CUDA实战》第五章 线程并行
▶ 本章介绍了线程并行,并给出四个例子.长向量加法.波纹效果.点积和显示位图. ● 长向量加法(线程块并行 + 线程并行) #include <stdio.h> #include &quo ...
- 如何在Spring异步调用中传递上下文
以下文章来源于aoho求索 ,作者aoho 1. 什么是异步调用? 异步调用是相对于同步调用而言的,同步调用是指程序按预定顺序一步步执行,每一步必须等到上一步执行完后才能执行,异步调用则无需等待上一步 ...
- 调用线程无法访问此对象,因为另一个线程拥有该对象 [c# wpf定时器程序报的错误]
WPF:Dispatcher.Invoke 方法,只有在其上创建 Dispatcher 的线程才可以直接访问DispatcherObject.若要从不同于在其上创建 DispatcherObject ...
- WPF [调用线程无法访问此对象,因为另一个线程拥有该对象。] 解决方案以及如何实现字体颜色的渐变
本文说明WPF [调用线程无法访问此对象,因为另一个线程拥有该对象.] 解决方案以及如何实现字体颜色的渐变 先来看看C#中Timer的简单说明,你想必猜到实现需要用到Timer的相关知识了吧. C# ...
- WPF异常“调用线程无法访问此对象,因为另一个线程拥有该对象 ”
WPF中在对界面进行操作的时候,可能会遇到"调用线程无法访问此对象,因为另一个线程拥有该对象"异常,这是因为WPF中只有UI线程才能操作UI元素,非UI线程要访问UI时就会报异常了 ...
- WPF 之 调用线程必须为 STA,因为许多 UI 组件都需要
WPF中,代码中准备控制控件内容时,有时会报错:“ 调用线程必须为 STA,因为许多 UI 组件都需要 ”. 如在winform下面,使用多线程时,控件的值读取是可以的,但如果要更改,那么就必须进行一 ...
- WPF解决方案------调用线程无法访问此对象,因为另一个线程拥有该对象
WPF [调用线程无法访问此对象,因为另一个线程拥有该对象.] 解决方案 在这里以播放图片为例进行说明,代码如下: void _Timer_Elapsed(object sender, Elapsed ...
- 线程相关函数(2)-pthread_self()获取调用线程ID
获取调用线程tid #include <pthread.h>pthread_t pthread_self(void); 示例: #include <pthread.h> #in ...
随机推荐
- Python 获取计算机全名(fully qualified host name)
Python 获取计算机全名(fully qualified host name) import socket socket.getfqdn() socket.gethostname()
- php防攻击
客户端脚本植入 XSS跨站脚本攻击(跨站脚本攻击,输入(传入)自动执行恶意的HTML代码,如盗取用户Cookie.破坏页面结构.重定向到其它网站):过滤<,>&,"等特殊 ...
- Largest Rectangle in a Histogram POJ - 2559 (单调栈)
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base l ...
- python之迭代器与生成器
python之迭代器与生成器 可迭代 假如现在有一个列表,有一个int类型的12345.我们循环输出. list=[1,2,3,4,5] for i in list: print(i) for i i ...
- 平衡二叉树的java实现
转载请注明出处! 一.概念 平衡二叉树是一种特殊的二叉搜索树,关于二叉搜索树,请查看上一篇博客二叉搜索树的java实现,那它有什么特别的地方呢,了解二叉搜索树的基本都清楚,在按顺序向插入二叉搜索树中插 ...
- Unity IOC容器的构造函数使用笔记(不能错过的Unity示例)
示例一,正常使用: 相关定义: public interface ICar { int Run(); } public class BMW : ICar { ; public int Run() { ...
- babel那些事儿
从前,一提到新东西,我的反应就是兼容性好不好,如果不能满足产品经理的需求,就还是用保守的方式实现吧.毕竟前端开发是一件很灵活的事,怎么写都行,至于为何会用某种方法,一定是综合考虑兼容性,性能,用户体验 ...
- c#窗体form的美化
- [Python] Marshmallow QuickStart
常用小操作索引 指定fields必须:fields.String(required=True) 部分loading: 不load name:result = UserSchema.load({'ema ...
- bzoj3033: 太鼓达人 欧拉路径
题目链接 bzoj3033: 太鼓达人 题解 对于k-1位点,k位二进制位边,将点的转移连起来 每个点的入度和出度相等并且全部是偶点 只需要在这个图中找字典序最小的欧拉回路 可以贪心地找字典序较小的边 ...