I solved the problem by increasing the size of the stack by using utility EDITBIN from VisualStudio
editbin /STACK:6291456 "WpfApplication1.exe"
Unfortunately it doesn't work in VisualStudio by adding into Post-Build section in project properties. So I'd created the bat file, which is necessary to execute after build.