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 7167129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:31:40+00:00 2026-05-28T14:31:40+00:00

What I want to do is this– I want to make a proxy call

  • 0

What I want to do is this–

I want to make a proxy call to a service and receive data on a separate thread through an asynchronous callback…the tricky part is that I want to make the foreground thread sleep until all of the data has been retrieved.

The reason I’m not using a synchronous method to do this, is because I’m creating an API for a WCF service that uses Paging and returns data in chunks.
I want my client to be able to use Paging, but I don’t want to expose all of my Paging callbacks to my API…I want it to appear as though the API exposes a synchronous data retrieval method.

I’ve tried using a private static Semaphore (because it is thread agnostic,) that is accessible to the class methods and the callbacks, with a single unit capacity as a means to pause the execution.

First, I use a Semaphore.WaitOne() statement.
Then, I do a Proxy call in the foreground thread, and the service creates a thread that handles the data retrieval, and control is passed back to the client.
In the client, I immediately use a second Semaphore.WaitOne() statement.
This should pause the foreground thread execution, which it does.
Then, once the “Paging Completed” Callback is executed on a separate thread, I use Semaphore.Release()
But the foreground thread never traverses the second Semaphore statement, it stays locked and so the client freezes.

Any ideas what I am doing incorrectly, or is there another locking design that would be more effective?

  • 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-28T14:31:41+00:00Added an answer on May 28, 2026 at 2:31 pm

    If what you’re trying to accomplish is having the foreground thread wait on data-gathering thread, you may want to consider using Tasks, which would allow you to easily accomplish what you’ve described here.

    System.Threading.Tasks:
    http://msdn.microsoft.com/en-us/library/dd235608.aspx

    Some code:

    Task t = new Task(somethingToDo);
    // Fire off the new task
    t.Start();
    
    // Wait for the task to finish...
    t.Wait();
    
    // Do something else...
    

    Make sure to take a look at the details of t.Wait() in the documentation. There are some exceptions you will want to be ready for, in the event that your task fails.

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

Sidebar

Related Questions

i want make function like that function(data){ } i want this data as this
I want this class to initialize to receive a message to be saved and
I want this data to be displayed in the tableview . can anyone tell
I really want this so I can serialize / deserialize some complex data objects
I want this work to be done in a different thread but do i
I want to make this sort of Pinterest effect on my registration form -
I want this highchart - http://jsfiddle.net/zPDca/ inside a popup. But if i decrease its
I want this text all on one line, not spaced on two sepearate lines.
I want this function (defn ret-lowest-str-len Computes the lengths of two strings. Returns default
I want this to open on mouse over then close again when the mouse

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.