Web Service Threading and State
-
Hi all, I have an issue and I'd like to find a cleaner solution (as, right now, my work around is dirty beyond recognition ;P ). This is the structure "Search" (A web service method) is called by Web Site "Search" calls two other Web Service methods Asynchronously Each Async method calls a "Completed" method (one each) and each "Completed" method checks if the other one was finished before it Once both Async calls have been finished another method ("Connect Results") is called by the last finished "Completed" method "Connect Results" gathers data from two files (saved from each async method) and joins them into one instance of a class "Final Result" which needs to be returned BUT since the method "Search" needs a return and because the return line is reached before any of the threads have finished executing, the return is always empty. So I inserted a while loop (which checks that "Final Result" is not empty) before the last "return" line of "Search" which does nothing except wait for the class to be filled! I'm sure there's some other way to do this... something cleaner but I can't seem to find it. Thanks for your help and sorry for the long post...
In life truth does not matter. What really matters is what others believe to be the truth. (The Up and Comer - Book)