Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:15:58+00:00 2026-05-30T23:15:58+00:00

I have a method that calls two services from PHP at the same time.

  • 0

I have a method that calls two services from PHP at the same time. Due to multi-tasking abilities of Flex, I think that each service is called in a different thread.

My problem is: Both services return an Array of Objects from the database. But the second service will feed a DataGrid that has a handler for each record. This handler will compare that from both Arrays and when Flex finishes the second one before finishes the first one, I have a problem because the handler tries to compare data with a null object (the PHP Service didn’t respond yet).

Any ideas?

EDIT:

On the day that I posted this question, some guy gave me an amazing idea, but sadly seems like he deleted his post, I don’t know why.
I kept his idea on my mind and I found a solution that fits my design pattern with his idea.

He told me to put a flag telling me if the data was already loaded or not.
So here is what I’m doing now:
I call first service;
I call second service;

On the result of first service, I check the Flag on the second service, if it’s true, it means that it was already loaded, so I can just store my data in the DataGrid so the handler can be called.
If the flag is false, it means that the second data wasn’t loaded yet, so instead of storage the data in the official dataProvider, I storage it on a _temp DataProvider that is not BOUND to the dataGrid. In this case, when the second data is loaded, a listener event is dispatched to the first service telling him to catch the _temp dataProvider and copy that to the official dataProvider.

Particularly, I liked the solution and it doesn’t break the Table Data Gateway design pattern.

Thanks everyone for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:15:59+00:00Added an answer on May 30, 2026 at 11:15 pm

    Due to multi-tasking abilities of Flex, I think that each service is
    called in a different thread.

    What makes you think Flex supports multi-threading? It really doesn’t. Single Thread only.

    However, your calls are asynchronous in that when they are sent, the program does not stop to wait for an answer, but listens for a completion event.

    Your solution is simple: Send only the first request, wait for it to complete, and then send the second request in the completion handler.

    EDIT

    To preserve your design pattern, you can apply two different strategies:

    1. Use the Business Delegate pattern: Have a custom class act as the gateway and encapsulate the actual connections to your services. It could then dispatch its own COMPLETE event to trigger the handlers you have. To the DataGrid, it would appear like a single asynchronous call.

    2. Use the Session Facade pattern: Create a single service on the server side, which accepts a single request, calls the referenced services locally, and returns the combined data for both services in a single response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a subclass that calls a method from a superclass. The method in
I have a method that calls a service to retrieve an instance of an
If I have a method that calls itself under a certain condition, is it
I have a service method that calls a DAO which then returns an object
I have a method song_link that calls link_to internally. I want the caller to
I have created a console application that calls a method on a webservice. I
Setup: I have a COM DLL that calls a method inside a managed C#
I have a unit test that creates a mock calls my method to be
I have a method that I call and it returns bitmap data from a
I have a flex application that communicates via BlazeDS with two webapps running inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.