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的更多相关文章

  1. C#线程 并行线程

    第五部分 并行线程   在本节中,我们将介绍Framework 4.0新增的利用多核处理器的多线程API: 并行LINQ或PLINQ Parallel 类 任务并行性构造 并发集合 自旋锁和自旋等待 ...

  2. 《GPU高性能编程CUDA实战》第五章 线程并行

    ▶ 本章介绍了线程并行,并给出四个例子.长向量加法.波纹效果.点积和显示位图. ● 长向量加法(线程块并行 + 线程并行) #include <stdio.h> #include &quo ...

  3. 如何在Spring异步调用中传递上下文

    以下文章来源于aoho求索 ,作者aoho 1. 什么是异步调用? 异步调用是相对于同步调用而言的,同步调用是指程序按预定顺序一步步执行,每一步必须等到上一步执行完后才能执行,异步调用则无需等待上一步 ...

  4. 调用线程无法访问此对象,因为另一个线程拥有该对象 [c# wpf定时器程序报的错误]

    WPF:Dispatcher.Invoke 方法,只有在其上创建 Dispatcher 的线程才可以直接访问DispatcherObject.若要从不同于在其上创建 DispatcherObject ...

  5. WPF [调用线程无法访问此对象,因为另一个线程拥有该对象。] 解决方案以及如何实现字体颜色的渐变

    本文说明WPF [调用线程无法访问此对象,因为另一个线程拥有该对象.] 解决方案以及如何实现字体颜色的渐变 先来看看C#中Timer的简单说明,你想必猜到实现需要用到Timer的相关知识了吧. C# ...

  6. WPF异常“调用线程无法访问此对象,因为另一个线程拥有该对象 ”

    WPF中在对界面进行操作的时候,可能会遇到"调用线程无法访问此对象,因为另一个线程拥有该对象"异常,这是因为WPF中只有UI线程才能操作UI元素,非UI线程要访问UI时就会报异常了 ...

  7. WPF 之 调用线程必须为 STA,因为许多 UI 组件都需要

    WPF中,代码中准备控制控件内容时,有时会报错:“ 调用线程必须为 STA,因为许多 UI 组件都需要 ”. 如在winform下面,使用多线程时,控件的值读取是可以的,但如果要更改,那么就必须进行一 ...

  8. WPF解决方案------调用线程无法访问此对象,因为另一个线程拥有该对象

    WPF [调用线程无法访问此对象,因为另一个线程拥有该对象.] 解决方案 在这里以播放图片为例进行说明,代码如下: void _Timer_Elapsed(object sender, Elapsed ...

  9. 线程相关函数(2)-pthread_self()获取调用线程ID

    获取调用线程tid #include <pthread.h>pthread_t pthread_self(void); 示例: #include <pthread.h> #in ...

随机推荐

  1. POJ 1979 红与黑

    题目地址: http://poj.org/problem?id=1979  或者  https://vjudge.net/problem/OpenJ_Bailian-2816 Red and Blac ...

  2. Java 之 JQuery

    1.JQuery a.定义:jQuery 是一个 JavaScript 库 b.作用:极大地简化了 JavaScript 编程 c.引入: <script src="jquery.js ...

  3. python3 在 windows 读取路径多了一个\u202a 是咋回

    python3 在 windows 读取路径多了一个\u202a 是咋回事

  4. POJ 3275 Ranking the Cows(传递闭包)【bitset优化Floyd】+【领接表优化Floyd】

    <题目链接> 题目大意:FJ想按照奶牛产奶的能力给她们排序.现在已知有N头奶牛$(1 ≤ N ≤ 1,000)$.FJ通过比较,已经知道了M$1 ≤ M ≤ 10,000$对相对关系.每一 ...

  5. SQL 2016 正式版 安装过程

    1.点击全新安装 2.接着就是下一步,下一步... 3.选择你要安装的功能    [可以利用PolyBase,使用标准TSQL查询hadoop数据,但这里我不需要装] 4.设置排序规则 5.设置登录用 ...

  6. 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛.B.跳一跳,很简单的(Hash 倍增)

    题目链接 首先变换的周期是\(26\),而所有字符是同时变的,所以一共就只有\(26\)种树,我们对\(26\)棵树分别处理. 求某节点到根路径上的字符串,可以从根往下哈希,\(O(n)\)预处理出. ...

  7. NEO学习笔记,从WIF到地址

    2018开年,先给大家拜个年,Happy Neo Year. 开年总得写点什么,就打算继续开学习笔记系列,一点一点仔细的去分析NEO. 今天说一说从WIF到地址的这一串关系.   简单说就一张图: 或 ...

  8. BZOJ4858 : [Jsoi2016]炸弹攻击 2

    枚举每个$S$作为原点,将所有$D$和$T$极角排序. 枚举每个$T$,那么另一个$T$需要和当前的$T$夹角不超过$180$度,贡献为内部$D$的个数. 双指针后用前缀和查询区间的贡献即可. 时间复 ...

  9. H5微信单页读书日活动

    1. 页面方面 (1)单页面应用,使用jquery 绑定click事件来控制页面更换显示 (2)ajax请求获取图片数据,和海报名人名言数据 2.微信分享 (1)配置签名,后台导入微信第三方库配置签名 ...

  10. yii2过滤器(filter)

    一.VerbFilter VerbFilter检查请求动作的HTTP请求方式是否允许执行, 如果不允许,会抛出HTTP 异常 use yii\filters\VerbFilter; public fu ...