private void EndMainThread()
 {
     // join child thread
     while (true)
     {
         manager.SyncVarAccess(taskid, MSyncVarOp.TASK_JOIN);
         if (childdone)
         {
             break; // done
         }
         manager.LocalBacktrack();
     }
     manager.CommitSyncVarAccess();
 }
Example #2
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);
        }