473,471 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Remoting, Singleton and BackGroundWorker problem

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 problem earlier today where the EventShims that my clients were
invoking to handle server -Client events were expiring and I was getting
the "Service not found" exception. I solved it by returning null from
InitializeLifetimeService()

I think the new problem I have is related.

My main proxy object or remoting object starts a Background Worker in it's
c'tor to poll a web service for data.
When my first client connects it instantiates the Singleton remote object,
all subsequent clients use this singleton. You can see this from the sample
server output below:
<server log>
OfficeStudio Server Started. Press ENTER to exit.
FaxManager Instance created
--------------------------------------------
| Poller Process Started |
--------------------------------------------
19 seconds until next server hit
Registered Client PC - 1 total clients registered.
18 seconds until next server hit
17 seconds until next server hit
16 seconds until next server hit
15 seconds until next server hit
Registered Client PC - 2 total clients registered.
14 seconds until next server hit
13 seconds until next server hit
12 seconds until next server hit
11 seconds until next server hit
Registered Client PC - 3 total clients registered.
10 seconds until next server hit
9 seconds until next server hit
8 seconds until next server hit
Registered Client PC - 4 total clients registered.
7 seconds until next server hit
6 seconds until next server hit
5 seconds until next server hit
Registered Client PC - 5 total clients registered.
4 seconds until next server hit
3 seconds until next server hit
2 seconds until next server hit
1 seconds until next server hit
Last checked for new faxes: 1/11/2008 1:55:18 AM
</server log>

Now, the problem arises when I close down all the clients and don't open
another one for several minutes (I haven't timed it yet, but I bet it's
00:05:01 (default expiration time for a remote object)

When this happens I will see in the server log that the remote object's
c'tor has been called again and another Background Worker instantiated, etc.
Problem is the FIRST BG worker is still cranking along hitting the web
service. So as this scenario plays out over and over I have n background
workers stacking up and they are blasting the web service which will
eventually make someone unhappy ;0)

My question is... when the remote object's lease expires... shouldn't it
call it's destructor and as such dispose the BackGroundWorker? Maybe I'm
misunderstanding the lease concept, it could be that the CLIENT's lease on
the object expires and the object is indeed still valid on the server.
IF this is the case, why do subsequent clients not get this already existing
singleton remote instance? Why are they creating a new one?

I suspect that I have a flaw in my over all design and I accept that, but
until I have time to take a second pass on the whole thing I need to figure
out what is happening here.

If anyone can shed some light on this I would really appreciate it. I'm
hoping to deploy the server over the weekend to let it crank away without
the risk of screwing up the office staff.

Thanks,
Steve
Jan 11 '08 #1
1 2433
This article sheds some light:
http://thoughtshapes.com/node/49

Apparently the Singleton remote object is actually a monostate. Although
that still doesn't explain why the BackGroundWorker isn't collected.

I'd still appreciate any input you may have.
-Steve

"Steve K." <no***@nowhere.comwrote in message
news:eG**************@TK2MSFTNGP04.phx.gbl...
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 problem earlier today where the EventShims that my clients were
invoking to handle server -Client events were expiring and I was getting
the "Service not found" exception. I solved it by returning null from
InitializeLifetimeService()

I think the new problem I have is related.

My main proxy object or remoting object starts a Background Worker in it's
c'tor to poll a web service for data.
When my first client connects it instantiates the Singleton remote object,
all subsequent clients use this singleton. You can see this from the
sample server output below:
<server log>
OfficeStudio Server Started. Press ENTER to exit.
FaxManager Instance created
--------------------------------------------
| Poller Process Started |
--------------------------------------------
19 seconds until next server hit
Registered Client PC - 1 total clients registered.
18 seconds until next server hit
17 seconds until next server hit
16 seconds until next server hit
15 seconds until next server hit
Registered Client PC - 2 total clients registered.
14 seconds until next server hit
13 seconds until next server hit
12 seconds until next server hit
11 seconds until next server hit
Registered Client PC - 3 total clients registered.
10 seconds until next server hit
9 seconds until next server hit
8 seconds until next server hit
Registered Client PC - 4 total clients registered.
7 seconds until next server hit
6 seconds until next server hit
5 seconds until next server hit
Registered Client PC - 5 total clients registered.
4 seconds until next server hit
3 seconds until next server hit
2 seconds until next server hit
1 seconds until next server hit
Last checked for new faxes: 1/11/2008 1:55:18 AM
</server log>

Now, the problem arises when I close down all the clients and don't open
another one for several minutes (I haven't timed it yet, but I bet it's
00:05:01 (default expiration time for a remote object)

When this happens I will see in the server log that the remote object's
c'tor has been called again and another Background Worker instantiated,
etc. Problem is the FIRST BG worker is still cranking along hitting the
web service. So as this scenario plays out over and over I have n
background workers stacking up and they are blasting the web service which
will eventually make someone unhappy ;0)

My question is... when the remote object's lease expires... shouldn't it
call it's destructor and as such dispose the BackGroundWorker? Maybe I'm
misunderstanding the lease concept, it could be that the CLIENT's lease on
the object expires and the object is indeed still valid on the server.
IF this is the case, why do subsequent clients not get this already
existing singleton remote instance? Why are they creating a new one?

I suspect that I have a flaw in my over all design and I accept that, but
until I have time to take a second pass on the whole thing I need to
figure out what is happening here.

If anyone can shed some light on this I would really appreciate it. I'm
hoping to deploy the server over the weekend to let it crank away without
the risk of screwing up the office staff.

Thanks,
Steve

Jan 11 '08 #2

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

Similar topics

2
by: Fadi | last post by:
Backround: I am trying to figure out how to do the equivalant of a classic COM Local Server Singleton in .NET/C#. I created a coupld of simple Class Libs that exposes public interfaces and hosted...
1
by: 2G | last post by:
Hi, It seems I can't get remoting to work when my mbrobject is in a larger namespace. I doing ingo's book and when I do the example like it says in the book, all works fine <configuration> ...
9
by: Nak | last post by:
Hi there, I have been messing around with remoting in an attempt to create a "shared application" as mentioned in another thread by that name. I have created a singleton object just like the...
3
by: S Chapman | last post by:
I have a simple remote server object that raises an event when the list maintined by it changes. The idea is to enable the remote client to update the GUI when the server list changes. When the I...
5
by: mitch | last post by:
Hello, Basically, I want my application to run only one instance at a time and pass command line arguments to a running instance. I have all of this working, I used the IPC Remoting channel and...
6
by: Palvinder Singh | last post by:
Hello google group peeps, I am new to remoting, but have a grasp of it. I am trying to create a server/client application, which will be deployed over an intranet. I have upwards of five...
13
by: José Joye | last post by:
Hello, What is the best way to stop a remoting server (Singleton SAO) that has been started with RemotingConfiguration.Configure(). For sure, I want to do this without quitting the application...
2
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
0
by: William | last post by:
Hi I'm busy developing a .NET remoting application. Tcp remoting with a binary formatter is used. The user can specify on the client configuration whether to connect to the hosted Singleton or...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.