Exemple #1
0
 /// <summary>
 /// Blocks the calling thread until the thread represented by this instance terminates,
 /// while continuing to perform standard COM and SendMessage pumping.
 /// </summary>
 /// <param name="thread">The thread to join.</param>
 public static void Join(Thread thread)
 {
     if (CoyoteRuntime.IsExecutionControlled)
     {
         if (ThreadTasks.TryGetValue(thread, out Task task))
         {
             ControlledTask.Wait(task);
             thread.Join();
         }
     }
     else
     {
         thread.Join();
     }
 }
Exemple #2
0
        /// <summary>
        /// Blocks the calling thread until the thread represented by this instance terminates
        /// or the specified time elapses, while continuing to perform standard COM and SendMessage
        /// pumping.
        /// </summary>
        /// <param name="thread">The thread to join.</param>
        /// <param name="timeout">
        /// A System.TimeSpan set to the amount of time to wait for the thread to terminate.</param>
        /// <returns>
        /// true if the thread terminated; false if the thread has not terminated after the
        /// amount of time specified by the timeout parameter has elapsed.
        /// </returns>
        public static bool Join(Thread thread, TimeSpan timeout)
        {
            if (CoyoteRuntime.IsExecutionControlled)
            {
                if (ThreadTasks.TryGetValue(thread, out Task task))
                {
                    ControlledTask.Wait(task, timeout);
                    return(thread.Join(timeout));
                }
                else
                {
                    return(false);
                }
            }

            return(thread.Join(timeout));
        }
Exemple #3
0
        /// <summary>
        /// Blocks the calling thread until the thread represented by this instance terminates
        /// or the specified time elapses, while continuing to perform standard COM and SendMessage
        /// pumping.
        /// </summary>
        /// <param name="thread">The thread to join.</param>
        /// <param name="millisecondsTimeout">
        /// The number of milliseconds to wait for the thread to terminate.</param>
        /// <returns>
        /// true if the thread has terminated; false if the thread has not terminated after
        /// the amount of time specified by the millisecondsTimeout parameter has elapsed.
        /// </returns>
        public static bool Join(Thread thread, int millisecondsTimeout)
        {
            if (CoyoteRuntime.IsExecutionControlled)
            {
                if (ThreadTasks.TryGetValue(thread, out Task task))
                {
                    // TODO: support timeouts and cancellation tokens.
                    ControlledTask.Wait(task, millisecondsTimeout);
                    return(thread.Join(millisecondsTimeout));
                }
                else
                {
                    return(false);
                }
            }

            return(thread.Join(millisecondsTimeout));
        }