3 Replies Latest reply on Jun 24, 2008 6:55 AM by levancho

    Wait until complete some function and return result

    klebed
      Hello,
      I am new comer in as and flex, My problem is next
      :during invoking some function I should get data from server side and
      then return result in the same function

      override flash_proxy function getProperty(name:*):* {
      this.remoteObject.source = BOOK_SOURCE;
      var callOperation:AbstractOperation =service.getOperation(LOAD_METHOD);
      callOperation.addEventListener(ResultEvent.RESULT, resultMethodLoad);
      callOperation.send();

      return result;//here I want return result from resultMethodLoad function
      }

      private function resultMethodLoad(e:ResultEvent):* {
      return (e.result as ArrayCollection);
      }

      how I can to stop current thread invoking while get information from server and return result of resultMethodLoad
      without looping

      Thanks
        • 1. Re: Wait until complete some function and return result
          atta707 Level 2
          I don't think you can without a loop! But if even you could, why would you want to?

          ATTA
          • 2. Re: Wait until complete some function and return result
            student_it
            In an RIA, don't we need a way to control how service request results are received? Granted that looping sounds negative, it reduces potential race conditions on the middleware side. Otherwise, I will have to figure out ways to lock those screen widgets while this happens and that can get real ugly with lots of screen widgets. So I think it's easier to control from the service call. But does Flex support this model after all?

            Sincerely,
            Student_it
            • 3. Re: Wait until complete some function and return result
              levancho Level 3
              quote:

              Originally posted by: student_it
              In an RIA, don't we need a way to control how service request results are received? Granted that looping sounds negative, it reduces potential race conditions on the middleware side. Otherwise, I will have to figure out ways to lock those screen widgets while this happens and that can get real ugly with lots of screen widgets. So I think it's easier to control from the service call. But does Flex support this model after all?

              Sincerely,
              Student_it



              FLex and RIA in general do not fall under liniar development pattern, and this is due to many reason, and first of all is the reason of not having blocked froze screens, which for some strange reason you are trying to achive, even though you say you do not want to have frozen widgets....

              think about it , if it was as you are asking then all your program would be completely frozen untill service finished,
              and you never know how long service can take, implementing framework on assumption that all service calls are going to be lightning fast is very bad idea, that is why service calls do not return immediately and on top of it they let you move on with your code and will tap you on the shoulder when they are done giving you the result.