Good day.
void FunctionZ() { (new Thread(delegate() { Console.Writeln(0); FunctionA(); Console.Writeln(2); })).Start(); } void FunctionA() { (new Thread(delegate() { Console.Writeln(1); })).Start(); } The problem is that when FunctionZ is executed, the end of the FunctionA function is not expected, and the code just goes on. And you must first wait for the end of the execution of the FunctionA function and only then continue the execution.
UPD:
I specify a little, when executing the code, 0 2 1 is often displayed at the top. Although 0 1 2 should be displayed. FunctionA is not expected to be executed, and the following code is executed immediately. And you need to be expected.
FunctionArunning synchronously. Are you sure thatConsole.Writeln(2);Is your example in the right place? - VladD