EventHandling problem : Java has solution but what about Microsoft???

  • Thread starter Thread starter Herfried K. Wagner [MVP]
  • Start date Start date
I don't know how log4net handles this, but I guess it uses the Stack
also.
I have no idea about the rules compiler uses to decide to inline a
function, but the logging routines is in a separate class in a separate
assembly. Does the runtime ever decide to inline such methods?

Thi
 
Truong said:
I don't know how log4net handles this, but I guess it uses the Stack
also.
I have no idea about the rules compiler uses to decide to inline a
function, but the logging routines is in a separate class in a separate
assembly. Does the runtime ever decide to inline such methods?

Thi

AFAIK, the JIT currently inlines methods that have 32 or less IL bytes.
As for the problem, I think you don't need to worry about it, as it's
mostly theoretical. It can happen like this:

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Test
{
class Program
{
static void Main(string[] args)
{
Method1();
}

static void Method1()
{
Method2();
}

static void Method2()
{
WriteCallee();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void WriteCallee();
{
Console.WriteLine(new StackFrame(1).GetMethod().Name);
}
}
}

in debug mode (inlining disabled) the output is Method2, whereas in
release mode the output is Main

HTH,
Stefan
 
Back
Top