MMMHUHU
正确的方法是修复溢出,但是.你可以给自己一个更大的一叠:-using System.Threading;Thread T = new Thread(threadDelegate, stackSizeInBytes);T.Start();您可以使用System.Diagnostis.StackTrace FrameCount属性来计数您使用过的帧,并在达到框架限制时抛出您自己的异常。或者,您可以计算剩余堆栈的大小,并在堆栈低于阈值时抛出自己的异常:-class Program{
static int n;
static int topOfStack;
const int stackSize = 1000000; // Default?
// The func is 76 bytes, but we need space to unwind the exception.
const int spaceRequired = 18*1024;
unsafe static void Main(string[] args)
{
int var;
topOfStack = (int)&var;
n=0;
recurse();
}
unsafe static void recurse()
{
int remaining;
remaining = stackSize - (topOfStack - (int)&remaining);
if (remaining
throw new Exception("Cheese");
n++;
recurse();
}}抓住奶酪就行了。;)