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

  • Home
  • SEARCH
  • 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

I have a large-ish web project which is migrating from classic ASP to ASP.NET
I currently converted my website from classic asp to ASP.NET MVC, I'll be putting
I have a web site that runs both classic ASP and ASP.NET Webforms. The
Is it possible to call Server.Execute with a .NET .aspx page from classic ASP?
I am making the switch from classic ASP to ASP.NET. And I am having
I've ported a page from classic ASP to ASP.net. Part of what happens in
I am attempting to call an ASP.NET page from a classic ASP page on
Given: I have a website that includes both ASP.NET Web Forms and Classic ASP
In the transition from classic ASP to Asp.Net some developers took to putting their
I'm evaluating a migration from a classic ASP 3.0 application to ASP.NET MVC. I've

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.