////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int EnumThreads (out IEnumDebugThreads2 ppEnum)
    {
      // 
      // Enumerates the threads that are running in this program.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        List<IDebugThread2> threads = new List<IDebugThread2> ();

        threads.AddRange (m_debugThreads.Values);

        ppEnum = new DebuggeeThread.Enumerator (threads);

        if (ppEnum == null)
        {
          throw new InvalidOperationException ();
        }

        return Constants.S_OK;
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        ppEnum = null;

        return Constants.E_FAIL;
      }
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumThreads(out IEnumDebugThreads2 ppEnum)
        {
            //
            // Enumerates the threads that are running in this program.
            //

            LoggingUtils.PrintFunction();

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                List <IDebugThread2> threads = new List <IDebugThread2> ();

                uint count;

                {
                    LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.EnumThreads(out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugThread2 [] threadArray = new IDebugThread2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, threadArray, ref count));

                    threads.AddRange(threadArray);
                }

                {
                    LoggingUtils.RequireOk(AttachedEngine.JavaDebugger.JavaProgram.EnumThreads(out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugThread2 [] threadArray = new IDebugThread2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, threadArray, ref count));
                }

                ppEnum = new DebuggeeThread.Enumerator(threads);

                if (ppEnum == null)
                {
                    throw new InvalidOperationException();
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                ppEnum = null;

                return(Constants.E_FAIL);
            }
        }