Hello,
I am facing some serious problems in my C# application probably due to
compiler/JIT optimization. Let is give an hypothetical example that
demonstrates the problem I am running into
class class1 {
public static string func(string param) {
string processedvalue;
//Process the param and return the value
...
...
...
return processedvalue;
}
}
class class2 {
static string x=class1.func("testparam");
public string func() {
return x;
}
class MainClass {
[STAThread]
static void Main(string[] args) {
class2 x=new class2();
x.func();
class2 y=new class2();
y.func();
}
}
Now, class1.func() function is getting called only once. Although it
is passed same parameter the return value of the function may differ
depending upon some external factors.
I want to ensure, that, class1.func() is always called and not
optimized at all.
Is there any way to tell compiler/JIT not to do any optmization for
call to class1.func at all. I know that removing static for varible
class2.x solves this problem. However, I don't want to do that, as,
there are too many places II would need to do that in my application.
-Prasad