int IDebugProgram2.Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            Debug.WriteLine("AD7ProgramNode: Entering Step");
            if (sk == enum_STEPKIND.STEP_BACKWARDS)
            {
                return(VSConstants.E_NOTIMPL);
            }

            Thread thread = new Thread(new ThreadStart(() => {
                // Just to ensure main method returns before running thread.
                Thread.Sleep(10);
                SteppingTypeEnum stepping = SteppingTypeEnum.None;
                switch (sk)
                {
                case enum_STEPKIND.STEP_INTO:
                    stepping = SteppingTypeEnum.StepInto;
                    break;

                case enum_STEPKIND.STEP_OVER:
                    stepping = SteppingTypeEnum.StepOver;
                    break;

                case enum_STEPKIND.STEP_OUT:
                    stepping = SteppingTypeEnum.StepOut;
                    break;
                }
                DebuggerManager.Instance.SteppingType = stepping;
                DebuggerManager.Instance.Run();
                //Debugger.Step();
            }));

            thread.Start();
            return(VSConstants.S_OK);
        }
 internal void CheckBreakpoints(int line, int colNumber, CommonTree ct)
 {
   int startColumn = 0;
   int endColumn = UInt16.MaxValue;
   int startLine = 0;
   int endLine = 0;
   RoutineInfo ri = CurrentScope.OwningRoutine;
   if ( (ct != null) && 
     ( Cmp( ct.Text, "if" ) != 0 ) && ( Cmp( ct.Text, "while" ) != 0 ) &&
     ( Cmp( ct.Text, "repeat" ) != 0 ) && ( Cmp( ct.Text, "loop" ) != 0 ) &&
     ( Cmp( ct.Text, "case_stmt" ) != 0 ) && ( Cmp( ct.Text, "declare_handler" ) != 0 ))
   {
     IToken tkStart = ri.TokenStream.Get(ct.TokenStartIndex);
     IToken tkEnd = ri.TokenStream.Get(ct.TokenStopIndex + 1);
     if (tkEnd == null)
       tkEnd = ri.TokenStream.Get(ct.TokenStopIndex);
     startColumn = tkStart.CharPositionInLine;
     endColumn = tkEnd.CharPositionInLine + 1;
     startLine = tkStart.Line;
     endLine = tkEnd.Line;
   }
   else
   {
     startLine = endLine = line;
     startColumn = colNumber;
   }
   int hash = GetTagHashCode(ri.SourceCode);
   string routineName = ri.GetFullName(_utilCon.Database);
   Breakpoint fakeBreakpoint = new Breakpoint( this ) { StartLine = startLine, EndLine = endLine, IsFake = true, Hash = hash, 
     RoutineName = routineName, StartColumn = startColumn, EndColumn = endColumn };
   CurrentScope.CurrentPosition = fakeBreakpoint;
   // Breakpoints on the same line but different files are treated by making a breakpoint uniquely identified
   // by line number and hash of current routine source code.
   if (OnBreakpoint == null) return;
   if (SteppingType != SteppingTypeEnum.StepOver)
   {
     stepOverScope = __scopeLevel;
   }
   if (SteppingType == SteppingTypeEnum.StepOver)
   {
     bool fireBp = false;
     if (stepOverScope != -1)
     {
       if (__scopeLevel == stepOverScope)
       {
         fireBp = true;
       }
     }
     else
       fireBp = true;
     if (fireBp)
       RaiseBreakpoint(fakeBreakpoint);
     return;
   }
   else if (SteppingType == SteppingTypeEnum.StepInto)
   {
     RaiseBreakpoint(fakeBreakpoint);
     return;
   }
   else if (SteppingType == SteppingTypeEnum.StepOut)
   {
     nextStepOut = _scopeLevel - 1;
     SteppingType = SteppingTypeEnum.None;
   }
   else if (nextStepOut != -1)
   {
     if (_scopeLevel == nextStepOut)
     {
       nextStepOut = -1;
       RaiseBreakpoint(fakeBreakpoint);
       return;
     }
   }
   BreakpointKey bpKey = new BreakpointKey() { Line = line, Hash = hash };
   Breakpoint bp = null;
   if (_breakpoints.TryGetValue(bpKey, out bp) && !bp.Disabled)
   {
     stepOverScope = __scopeLevel;
     HitBreakpoint(bp);
   }
 }