Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ OnValuesChanged()

static void System.Threading.ExecutionContext.OnValuesChanged ( ExecutionContext previousExecutionCtx,
ExecutionContext nextExecutionCtx )
inlinestaticpackage

Definition at line 239 of file ExecutionContext.cs.

240 {
241 IAsyncLocal[] array = previousExecutionCtx?.m_localChangeNotifications;
242 IAsyncLocal[] array2 = nextExecutionCtx?.m_localChangeNotifications;
243 try
244 {
245 if (array != null && array2 != null)
246 {
247 IAsyncLocal[] array3 = array;
248 foreach (IAsyncLocal asyncLocal in array3)
249 {
250 previousExecutionCtx.m_localValues.TryGetValue(asyncLocal, out var value);
251 nextExecutionCtx.m_localValues.TryGetValue(asyncLocal, out var value2);
252 if (value != value2)
253 {
254 asyncLocal.OnValueChanged(value, value2, contextChanged: true);
255 }
256 }
257 if (array2 == array)
258 {
259 return;
260 }
261 IAsyncLocal[] array4 = array2;
262 foreach (IAsyncLocal asyncLocal2 in array4)
263 {
264 if (!previousExecutionCtx.m_localValues.TryGetValue(asyncLocal2, out var value3))
265 {
266 nextExecutionCtx.m_localValues.TryGetValue(asyncLocal2, out var value4);
267 if (value3 != value4)
268 {
269 asyncLocal2.OnValueChanged(value3, value4, contextChanged: true);
270 }
271 }
272 }
273 return;
274 }
275 if (array != null)
276 {
277 IAsyncLocal[] array5 = array;
278 foreach (IAsyncLocal asyncLocal3 in array5)
279 {
280 previousExecutionCtx.m_localValues.TryGetValue(asyncLocal3, out var value5);
281 if (value5 != null)
282 {
283 asyncLocal3.OnValueChanged(value5, null, contextChanged: true);
284 }
285 }
286 return;
287 }
288 IAsyncLocal[] array6 = array2;
289 foreach (IAsyncLocal asyncLocal4 in array6)
290 {
291 nextExecutionCtx.m_localValues.TryGetValue(asyncLocal4, out var value6);
292 if (value6 != null)
293 {
294 asyncLocal4.OnValueChanged(null, value6, contextChanged: true);
295 }
296 }
297 }
298 catch (Exception exception)
299 {
300 Environment.FailFast(SR.ExecutionContext_ExceptionInAsyncLocalNotification, exception);
301 }
302 }

References System.array, System.Runtime.Serialization.Dictionary, System.exception, System.SR.ExecutionContext_ExceptionInAsyncLocalNotification, System.Environment.FailFast(), System.Threading.IAsyncLocal.OnValueChanged(), and System.value.

Referenced by System.Threading.ExecutionContext.ResetThreadPoolThread(), System.Threading.ExecutionContext.RestoreChangedContextToThread(), and System.Threading.ExecutionContext.RunForThreadPoolUnsafe< TState >().