Ejemplo n.º 1
0
        public static void WaitUntil([NotNull] this Thread thread, TimeSpan interval, int waitIterations)
        {
            thread         = thread.ArgumentNotNull();
            waitIterations = waitIterations.ArgumentInRange(paramName: nameof(waitIterations), lower: 0);

            DateTime stopAt = DateTime.Now.Add(interval);

            do
            {
                Thread.SpinWait(waitIterations);
            } while (thread.IsAlive && DateTime.Now < stopAt);
        }
Ejemplo n.º 2
0
 public static void WaitUntil([NotNull] this Thread thread, TimeSpan interval)
 {
     WaitUntil(thread.ArgumentNotNull(), interval, 0);
 }
Ejemplo n.º 3
0
        public static bool TrySetPriority([NotNull] this Thread thread, ThreadPriority priority = ThreadPriority.Normal)
        {
            thread.ArgumentNotNull().Priority = priority.ArgumentDefined();

            return(true);
        }