首页 > 解决方案 > step into skips method in visual studio 2015

问题描述

I want to debug step by step my code but the debugger skips my function method whenever I click the step into option in Visual Studio 2015.

My code

   _watch.Created += this.FileCreated;

   public void FileCreated(object sender, FileSystemEventArgs e1)
   {
      // some code
   }

I attached a break point to _watch.Created += this.FileCreated; and then I clicked the step into option but the debugger skips the FileCreated method. Can anyone tell me how to step into this method?

标签: c#visual-studiodebuggingvisual-studio-debugging

解决方案


Putting a break point on

_watch.Created += this.FileCreated;

won't trigger the method. It's assigning the method to run when Created is invoked.

You want to put a break point on

public void FileCreated(object sender, FileSystemEventArgs e1)

and then, when the Created event is invoked, your break point will hit and you can step into the method.

Links from comments:

Raising and Handling Events MSDN

Examples of raising and consuming events


推荐阅读