TryEnter() public static method

public static TryEnter ( object obj ) : bool
obj object
return bool
コード例 #1
0
        /// <summary>Gets an enumerable of the tasks currently scheduled on this scheduler.</summary>
        /// <returns>An enumerable of the tasks currently scheduled.</returns>
        protected sealed override IEnumerable <Task> GetScheduledTasks()
        {
            bool lockTaken = false;

            try
            {
                Monitor.TryEnter(_tasks, ref lockTaken);
                if (lockTaken)
                {
                    return(_tasks);
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(_tasks);
                }
            }
        }
コード例 #2
0
 internal static void TryEnter(object obj, int millisecondsTimeout, ref bool taken)
 {
     taken = Monitor.TryEnter(obj, millisecondsTimeout);
 }
コード例 #3
0
 internal static bool TryEnter(object obj, TimeSpan timeout)
 {
     return(Monitor.TryEnter(obj, timeout));
 }
コード例 #4
0
 internal static bool TryEnter(object obj, int millisecondsTimeout)
 {
     return(Monitor.TryEnter(obj, millisecondsTimeout));
 }
コード例 #5
0
 internal static void TryEnter(object obj, ref bool taken)
 {
     taken = Monitor.TryEnter(obj);
 }
コード例 #6
0
 internal static bool TryEnter(object obj)
 {
     return(Monitor.TryEnter(obj));
 }
コード例 #7
0
 public static bool TryEnter(object obj, TimeSpan timeout)
 {
     return(Monitor.TryEnter(obj, Monitor.MillisecondsTimeoutFromTimeSpan(timeout)));
 }