Ejemplo n.º 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, TimeSpan timespan)
 {
     return(Helper.SimpleWrap <bool>(
                delegate(ClrSyncManager m) { return JoinRaw(thread, m, (int)timespan.TotalMilliseconds); },
                delegate() { return thread.Join(timespan); }
                ));
 }
Ejemplo n.º 2
0
 public static int get_ManagedThreadId(Original::Thread thread)
 {
     return(Helper.SimpleWrap <int>(
                delegate(ClrSyncManager m) { return 10000 + m.GetChessTask(thread); },
                delegate() { return thread.ManagedThreadId; }
                ));
 }
Ejemplo n.º 3
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); }
                ));
 }
Ejemplo n.º 4
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); }
         );
 }
Ejemplo n.º 5
0
 public static void StartHelper(Original::Thread t, object o, bool parameterized)
 {
     Helper.SimpleDel <bool> common = delegate()
     {
         if (parameterized)
         {
             t.Start(o);
         }
         else
         {
             t.Start();
         }
         return(false);
     };
     Helper.SimpleWrap <bool>(
         delegate(ClrSyncManager manager)
     {
         ChessTask child             = manager.TaskFork();
         Original.Semaphore childSem = new Original.Semaphore(0, 1);
         manager.RegisterTaskSemaphore(child, childSem, true);
         manager.AddChildHandle(child, t);
         manager.TaskResume(child);
         common();
         return(false);
     },
         common);
 }
Ejemplo n.º 6
0
 public static Original::Thread ConstructThread <T>(MakeThreadDelegate <T> mt, T del, WrapThreadStartDelegate <T> wts)
 {
     return(Helper.SimpleWrap <Original::Thread>(
                delegate(ClrSyncManager manager)
     {
         // wrap the delegate
         Original::Thread ret = mt(wts(del, manager));
         return ret;
     },
                delegate()
     {
         return mt(del);
     }));
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 public static void Interrupt(Original::Thread thread)
 {
     throw new NotImplementedException("Thread.Interrupt (1).");
 }
Ejemplo n.º 9
0
 public static void Abort(Original::Thread thread, object o)
 {
     throw new NotImplementedException("Thread.Abort (2). You should avoid using this method. See http://msmvps.com/blogs/peterritchie/archive/2007/08/22/thead-abort-is-a-sign-of-a-poorly-designed-program.aspx for more detail.");
 }
Ejemplo n.º 10
0
 public static void Resume(Original::Thread thread)
 {
     throw new NotImplementedException("Thread.Resume has been deprecated");
 }
Ejemplo n.º 11
0
 public static void Suspend(Original::Thread thread)
 {
     throw new NotImplementedException("Thread.Suspend has been deprecated");
 }
Ejemplo n.º 12
0
 public static void Start(Original::Thread thread, object obj)
 {
     Helper.StartHelper(thread, obj, true);
 }
Ejemplo n.º 13
0
 public static void Start(Original::Thread thread)
 {
     Helper.StartHelper(thread, null, false);
 }