What is the stack size of a BackgroundWorker DoWork Thread? Is there way to change it?

空扰寡人 提交于 2019-12-01 11:04:39

The stack size inside a BackgroundWorker DoWork event is the same as for the main thread.

Prof:

Set the stack size in a post build event to 8 MB for example:

"$(DevEnvDir)..\..\VC\bin\editbin.exe" /STACK:8388608 "$(TargetPath)"

Then ask for the stack size using the following code:

[DllImport("kernel32.dll")]
internal static extern void GetCurrentThreadStackLimits(out uint lowLimit, out uint highLimit);


public static uint GetStackSize()
{
    uint low, high;
    GetCurrentThreadStackLimits(out low, out high);
    return high - low;
}

Using GetStackSize in the main program and in the DoWork event return in both cases 8 MB or whatever you specified using EDITBIN /STACK.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!