Suppose I have some code that looks like this:
public SomeMethod() {
foreach (x...)
{
if (SomeCondition)
{
var SomeVariable = x;
Task.Factory.StartNew(() => SomeOtherMethod(SomeVariable));
}
}
return SomeValue;
}
If SomeOtherMethod is called and started in a new thread, does a) SomeMethod wait until that thread is finished running before returning or b) the method return and then the threads of SomeOtherMethod just continue on their own even after SomeMethod returned?
Reason I ask is that I need to wait until all SomeOtherMethods finish before exit SomeMethod.
Thanks.