c# - Windows Form: StackOverflowException -
i building windows form in visual studio 2010 using c#. getting stackoverflowexception when hit button. found alternative ways solve had no luck.
program
class created, , there's execute
function within class that's doing intense calculation , such.
private void execute_click(object sender, eventargs e) { thread thread = new thread(new threadstart(execute)); thread.setapartmentstate(apartmentstate.sta); thread.start(); } private void execute() { console.writeline("1111"); program p = new program(); p.function = "mynewfunction"; p.inputfile = filetextbox.text; console.writeline("2222"); p.execute(); //somehow never reaches here }
when run it, console prints out 1111. i'm confused how assigning values create stackoverflowexception.
please help! thanks!
i suppose new program() creates program, calls p.execute() again creates new program() , call p.execute , on... infinite recursion leads stack overflow.
Comments
Post a Comment