4

I am currently writing a C# program. There is an accompanying algorithm and I wish to show its lines of code being executed on a different panel at its point of execution.

For instance if this line is being called for execution:

SolidBrush drawBrush = new SolidBrush(Color.Tan);

Then it needs to be typed down or in an appropriate way shown on a panel.

Is there a way that I can achieve this?

Or

If there is a way that allows me to know the point of execution, that too would suffice.

Daniel
  • 41
  • 1
  • What have you got so far? – meilke Oct 04 '13 at 06:32
  • I've got nothing on it actually. – Daniel Oct 04 '13 at 06:34
  • 1
    Code runs very fast, you would have to have good eyes to read it. See http://stackoverflow.com/questions/4900744/is-there-a-way-to-get-the-current-line-number-when-executing-code-c-sharp for some links to external blogs – andrewb Oct 04 '13 at 06:37
  • +1 I like your question. I don't know the answer waiting for a answer. Don't know it is possible (though debuggers do similar task) But definitely it is going to be very hard:) – Sriram Sakthivel Oct 04 '13 at 06:40
  • Its for a very simple algorithm. I could pan down the rate of execution to a perceivable rate and thereafter get it onto the panel. That's what I intend to do. – Daniel Oct 04 '13 at 06:41
  • @Daniel if you want so your application should be executed step by step with low rate, or simply you want to log all the executed code? – King King Oct 04 '13 at 06:46

1 Answers1

0

You may use StackFrame Class. Using line number of the code thats being executed you should be able to get the code line i'm sure.

  • GetFileLineNumber()

Gets the line number in the file that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.

  • GetFileName()

Gets the file name that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.

Kurubaran
  • 8,696
  • 5
  • 43
  • 65