• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

How do I instantiate the core object in a web service?

The problem I have is that I would like the web service to run and have access to an object which will not get re-instatiated each time the web service is called.

I'm thinking of a Singleton, of sorts.

Can anyone tell me how to do this with a web service?  I could set an initial value to null and call a constructor in that case.  But in the case of the second call to the web service, I'd like to see that value is not null and that I can use that object.

Am I making sense?

thanks,
nbw
0
newbieweb
Asked:
newbieweb
  • 3
  • 3
1 Solution
 
JimBrandleyCommented:
You could handle it with a property as:

private SingletonObject mSingleton = null;

public Singleton
{
   get
   {
      if (mSingleton == null)
     {
         mSingleton = new SingletonObject;
     }
      return mSingleton;
   }
}

Jim
0
 
newbiewebAuthor Commented:
what namespace declares a SingletonObject ?
0
 
newbiewebAuthor Commented:
I mean what

using

statement should I use so it will compile?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
JimBrandleyCommented:
Sorry - That was just the name I used for your "core" object. It is whatever you need it to be. Unless I misunderstood the question.

Jim
0
 
newbiewebAuthor Commented:
Oh, I see.

thanks.
0
 
JimBrandleyCommented:
My pleasure. Good luck.

Jim
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now