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 ...
随机推荐
- POJ 2251 Dungeon Master (非三维bfs)
Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 55224 Accepted: 20493 ...
- TF:Tensorflor之session会话的使用,定义两个矩阵,两种方法输出2个矩阵相乘的结果—Jason niu
import tensorflow as tf matrix1 = tf.constant([[3, 20]]) matrix2 = tf.constant([[6], [100]]) product ...
- ACM-ICPC Beijing 2016 Genius ACM(倍增+二分)
描述 给定一个整数 M,对于任意一个整数集合 S,定义“校验值”如下: 从集合 S 中取出 M 对数(即 2∗M 个数,不能重复使用集合中的数,如果 S 中的整 数不够 M 对,则取到不能取为止),使 ...
- Linux下的计划任务at,batch,crontab
0x00前言: 继上次的windows计划任务后,拓展研究下linux下的计划任务,能够执行计划任务有3个命令at,batch,crontab 所谓的计划任务就是定时启动某个程序,可以是一组shell ...
- SpringBoot邮件发送
这篇文章介绍springboot的邮件发送. 由于很简单就没有分出server和imp之类,只是在controller简单写个方法进行测试. 首先pom文件加入spring-boot-starter- ...
- java之XML
//转为XML格式 public static String ArrayToXml(Map<String, String> arr) { String xml = "<xm ...
- Codeforces.226D.The table(构造)
题目链接 \(Description\) 给定一个\(n\times m\)的矩阵\(A_{i,j}\),每次可以将一列或一行取负.求一个方案使得若干次操作后,每行每列的和都非负. \(n,m\leq ...
- Centos中安装perl
1.安装gcc,在虚拟机命令窗口中输入:yum install -y gcc 2.下载perl安装包输入命令:wget http://www.cpan.org/src/5.0/perl-5.16.1. ...
- VirtWire 注册教程
1 首先打开virtwire官方网站 网站地址:戳我 2 如果现实如下图所示,点击红色框中的网址连接.(网页中有Terms of Service可以读) 3 如果网页正常打开,点击“ORDERHOST ...
- BZOJ3273 : liars
枚举每个人,计算他必定是诚实者的情况下至少有几个人说谎,若超过$t$则他肯定是说谎者. 对于至少有几个人说谎,区间信息可以合并: 每个区间维护最左最右两个人$l,r$以及$f[i][j]$表示$l$和 ...