473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Singleton instance of web service?

Hi folks,

I'm just curious if it is possible to create a Singleton instance of a Web
Service? Currently I create my web services in VS 2005, and then in my
applications I add the Web Service via 'Add web Reference', which as you know
doubt no is a great and easy mechanism for getting the proxy class etc.. al
nice and quickly added to the project.

However, say in my project I have two forms, and both use the Web reference.
Instantiating an instance of the web service in each form, and using when
needed, and disposing when finished, must cause a bit of a performance hit
(especially in pocket pc). So I was thinking, how can one create a Singleton
instance of the web Service and use it throughout the application? Or is
there some other mechanism to achieve a similar result?

Thanks for any opinions.
Dav
Dec 21 '07 #1
2 3514
Hi folks,

I was thinking something maybe like this -

class SingletonService
{
private static SingletonService instance;
private static object padlock = new object();

private Mobile.Service.Service webService = new Mobile.Service.Service();

protected SingletonService()
{
}

public bool fLogin(string username, string password)
{
return webService.fLogin(username, password);
}

public static SingletonService Instance
{
get
{
lock (padlock)
{
if (instance == null)
{
instance = new SingletonService();
}
return instance;
}
}
}
}

Any views?

Best,
Dave
Dec 21 '07 #2
"davebythesea" <da**********@discussions.microsoft.comwrote in message
news:54**********************************@microsof t.com...
Hi folks,

I'm just curious if it is possible to create a Singleton instance of a Web
Service? Currently I create my web services in VS 2005, and then in my
applications I add the Web Service via 'Add web Reference', which as you
know
doubt no is a great and easy mechanism for getting the proxy class etc..
al
nice and quickly added to the project.

However, say in my project I have two forms, and both use the Web
reference.
Instantiating an instance of the web service in each form, and using when
needed, and disposing when finished, must cause a bit of a performance hit
(especially in pocket pc). So I was thinking, how can one create a
Singleton
instance of the web Service and use it throughout the application? Or is
there some other mechanism to achieve a similar result?
In general, I think it would be best to not solve performance problems
before they exist - you might be solving the wrong problem.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Dec 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sharon | last post by:
I wish to build a framework for our developers that will include a singleton pattern. But it can not be a base class because it has a private constructor and therefore can be inherit. I thought...
5
by: Bob | last post by:
Does anyone know of any adverse affects of using singleton data access objects in an ASP.NET Web Service? I've been forced to implement it this way but it just doesn't seem right to me. I haven't...
12
by: keepyourstupidspam | last post by:
Hi, I am writing a windows service. The code runs fine when I start the service when my machine is running but it fails to start automatically when the machine reboots. The code bombs out when...
2
by: mma | last post by:
hello everyone, i have a solution that contains the following project types: 1. Class library contains a singleton class that handles the data access (sql server 2005). 2. Windows service....
7
by: fredd00 | last post by:
Hi I'm just starting with singleton and would like to implement in my new web app. I have a question lets say i create a singleton DataHelper that holds a static SqlConnection object to...
9
by: oleggus | last post by:
I hope, I misunderstood some basics here and it is easy to solve.. I need a singleton object running on server which can be used(write and read) by different client interfaces - for example there...
3
weaknessforcats
by: weaknessforcats | last post by:
Design Pattern: The Singleton Overview Use the Singleton Design Pattern when you want to have only one instance of a class. This single instance must have a single global point of access. That...
1
by: Steve K. | last post by:
I'm working on my first remoting project. It's going well and I have one (that I know of!) bug left to work out. I understand how remote objects have leases and those leases expire. I fixed a...
3
by: stevewilliams2004 | last post by:
I am attempting to create a singleton, and was wondering if someone could give me a sanity check on the design - does it accomplish my constraints, and/or am I over complicating things. My design...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.