Beispiel #1
0
 // Blocks the calling thread until a thread terminates or the specified time elapses,
 // while continuing to perform standard COM and SendMessage pumping.
 public static bool Join(Original::Thread thread, int t)
 {
     return(Helper.SimpleWrap <bool>(
                delegate(ClrSyncManager m) { return JoinRaw(thread, m, t); },
                delegate() { return thread.Join(t); }
                ));
 }
Beispiel #2
0
 // Blocks the calling thread until a thread terminates or the specified time elapses,
 // while continuing to perform standard COM and SendMessage pumping.
 public static bool Join(Original::Thread thread, TimeSpan timespan)
 {
     return(Helper.SimpleWrap <bool>(
                delegate(ClrSyncManager m) { return JoinRaw(thread, m, (int)timespan.TotalMilliseconds); },
                delegate() { return thread.Join(timespan); }
                ));
 }
Beispiel #3
0
 // Blocks the calling thread until a thread terminates, while continuing to perform standard COM
 // and SendMessage pumping.
 public static void Join(Original::Thread thread)
 {
     Helper.SimpleWrap <bool>(
         delegate(ClrSyncManager m) { JoinRaw(thread, m, -1); return(true); },
         delegate() { thread.Join(); return(true); }
         );
 }
Beispiel #4
0
        private static bool JoinRaw(Original::Thread t, ClrSyncManager manager, int millisecondsTimeout)
        {
            if (millisecondsTimeout < Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException();
            }
            bool ret;

            while (true)
            {
                manager.SetMethodInfo("Thread.Join(" + millisecondsTimeout + ")");
                manager.SyncVarAccess(t, MSyncVarOp.TASK_JOIN);
                try
                {
                    ret = t.Join(0);
                }
                catch (Exception e)
                {
                    manager.CommitSyncVarAccess();
                    throw e;
                }
                if (ret)
                {
                    break;  // join succeeded
                }
                if (millisecondsTimeout >= 0)
                {
                    manager.MarkTimeout();
                    manager.CommitSyncVarAccess();
                    manager.TaskYield();
                    return(ret);
                }
                manager.LocalBacktrack();
            }
            manager.CommitSyncVarAccess();
            return(ret);
        }