/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/System.Management.Automation/engine/remoting/common/AsyncObject.cs
58 строк
1 KB
xtqqczze
Fix RCS1049: Simplify boolean comparison (#13994)
13 ноя 2020, 07:39
Не верифицирован
13 ноя 2020, 07:39
b521b85
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Threading; using Dbg = System.Management.Automation.Diagnostics; namespace System.Management.Automation.Remoting { /// <summary> /// Blocks caller trying to get the value of an object of type T /// until the value is set. After the set all future gets are /// unblocked. /// </summary> internal class AsyncObject<T> where T : class { /// <summary> /// Value. /// </summary> private T _value; /// <summary> /// Value was set. /// </summary> private readonly ManualResetEvent _valueWasSet; /// <summary> /// Value. /// </summary> internal T Value { get { bool result = _valueWasSet.WaitOne(); if (!result) { _value = null; } return _value; } set { _value = value; _valueWasSet.Set(); } } /// <summary> /// Constructor for AsyncObject. /// </summary> internal AsyncObject() { _valueWasSet = new ManualResetEvent(false); } } }