I have a startup function that calls a function which returns a boolean based on whether the set up is successful or not. True if successful, false if failed. I would like to start that function on a new thread and then check the status of the function: here is the code.
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(StartAdapter));
thread.Start();
My question is, how in that case would I check the return status of the startadapter method? Because my friend told me that I will not know the return status because it is started on another thread, and yet trying:
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(StartAdapter));
thread.Start();
bool result = StartAdapter();
would call the function twice, which is something I don’t want either. Does anybody have some insight into this?
How in this case would I check the boolean returned from the startadapter function?
.NET 3.5
for this case there is the
Task<T>class that executes on the ThreadPool (for example) and lets you know the return value after it’s finishedjust use: