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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:07:26+00:00 2026-05-11T09:07:26+00:00

In classic ASP.NET I’d persist data extracted from a web service in base class

  • 0

In classic ASP.NET I’d persist data extracted from a web service in base class property as follows:

   private string m_stringData;    public string _stringData     {  get {             if (m_stringData==null)                 {                     //fetch data from my web service                     m_stringData = ws.FetchData()                 }             return m_stringData;        }    } 

This way I could simply make reference to _stringData and know that I’d always get the data I was after (maybe sometimes I’d use Session state as a store instead of a private member variable).

In Silverlight with a WCF I might choose to use Isolated Storage as my persistance mechanism, but the service call can’t be done like this, because a WCF service has to be called asynchronously.

How can I both invoke the service call and retrieve the response in one method?

Thanks, Mark

  • 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. 2026-05-11T09:07:27+00:00Added an answer on May 11, 2026 at 9:07 am

    In your method, invoke the service call asynchronously and register a callback that sets a flag. After you have invoked the method, enter a busy/wait loop checking the flag periodically until the flag is set indicating that the data has been returned. The callback should set the backing field for your method and you should be able to return it as soon as you detect the flag has been set indicating success. You’ll also need to be concerned about failure. If it’s possible to get multiple calls to your method from different threads, you’ll also need to use some locking to make your code thread-safe.

    EDIT

    Actually, the busy/wait loop is probably not the way to go if the web service supports BeginGetData/EndGetData semantics. I had a look at some of my code where I do something similar and I use WaitOne to simply wait on the async result and then retrieve it. If your web service doesn’t support this then throw a Thread.Sleep — say for 50-100ms — in your wait loop to give time for other processes to execute.

    Example from my code:

    IAsyncResult asyncResult = null; try {     asyncResult = _webService.BeginGetData( searchCriteria, null, null );     if (asyncResult.AsyncWaitHandle.WaitOne( _timeOut, false ))     {         result = _webService.EndGetData( asyncResult );     } } catch (WebException e) {     ...log the error, clean up... } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from ASP.NET Webform and Classic ASP. I want to know what are the
I am moving from classic ASP to ASP.NET and have encountered what many of
I am VERY new to ASP.NET. I come from a VB6 / ASP (classic)
Let me qualify this question. I'm working on a classic ASP.NET application (Web Forms)
We currently have a classic ASP.NET web application which serves as our API. It
In classic ASP.NET Web Forms view engine, we can set the ContentType in the
We are in the process of migrating an ASP Classic/ASP.NET application from IIS 6
A classic ASP.NET app - AppSrv + MS SQL DB. Both servers are heavy-lifters
As a classic ASP developer about once a year since ASP.NET came out I
I have been developing in asp.net since its existence (also classic asp before that)

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.