473,320 Members | 2,202 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,320 software developers and data experts.

Guidance on remoting

Hello folks,

I appologize for the cross post, but I really need an answer on this:

I do not think that I am seeing the whole picture here. I would like to
create a windows service and a management console, using Visual Basic 2003.
The windows service part, I think, is easy enough. I am more concerned with
the remoting aspect of the project. Below is the general idea of my
approach, please correct my where I am wrong.

I would really appreciate any assistance on this, thanks.
First, let me ask some questions:

1. Why have I not seen a model that uses Delegate functions, it would seem
to be better than wrapping everything inside eventargs?

2. Must I use events to ask the server for infomation from the client?

3. Must I specify <Serializable()> on all eventargs classes?

4. What precuations must I take to prevent conflicts caused when two
clients ask to modify the same information? Say for example, a request of
the server to modify the same row in a database at the same time.

5. How do I return a value from the server?

For this illustration, lets pretend that I am creating a service that
processes tasks based on a schedule. The service would simple have a loop
that waits for work to be done:
While (Not bStop and not bPause)
'Check for tasks to perform at this time
'Create entry, task starting 'Database Log Entry
'Process the task 'Calls StartTask <-- Invokes Plug-in's Start()
'Create entry, task complete + (success value) 'Success Result is
returned by task object
'Check if task is repeating task 'Read database schedule, to see if this
is a recurring task
'Update next run time/date
Wend

Meanwhile, administrators may wish to interact with the service:

--Run Task
--Cancel Task
--Create Task
--Enable Task
--Disable Task
--Edit Task
--Delete Task
--View Task History
Assmebly: SericeRemoting.dll

Public Interface ITaskServer

Delegate Sub RunTask(ByVal TaskID As Integer)
Event OnRunTask As RunTask

Delegate Sub StopTask(ByVal TaskID As Integer)
Event OnStopTask As StopTask

Delegate Sub NewTask(ByVal TI As TaskInfo)
Event OnNewTask As NewTask

Delegate Sub DeleteTask(ByVal TaskID As Integer)
Event OnDeleteTask As DeleteTask

Delegate Sub DisableTask(ByVal TaskID As Integer)
Event OnDisableTask As DisableTask

Delegate Sub EnableTask(ByVal TaskID As Integer)
Event OnEnableTask As EnableTask

Delegate Sub TaskItem(ByVal TIEA As TaskInfoEventArgs)
Event OnTaskItem As TaskItem

Delegate Sub ClearHistory(ByVal TaskID As Integer)
Event OnClearHistory As ClearHistory

Delegate Sub ViewHistory(ByVal THs As TaskHistories)
Event OnViewHistory As ViewHistory

End Interface

Public Interface ITaskClient

Sub RunTask(ByVal TaskID As Integer)
Sub StopTask(ByVal TaskID As Integer)

Function NewTask(ByVal TI As TaskInfo) As Integer
Sub DeleteTask(ByVal TaskID As Integer)

Sub DisableTask(ByVal TaskID As Integer)
Sub EnableTask(ByVal TaskID As Integer)

Function TaskItem(ByVal TaskID As Integer) As TaskInfo
Sub EditTaskItem(ByVal TI As TaskInfo)

Function ViewHistory(ByVal TaskID As Integer) As TaskHistories
Sub ClearHistory(ByVal TaskID As Integer)

End Interface

Public Class RemotedObject
Implements ITaskServer
Implements ITaskClient

Public Event OnClearHistory(ByVal TaskID As Integer) Implements
ITaskServer.OnClearHistory
Public Event OnDeleteTask(ByVal TaskID As Integer) Implements
ITaskServer.OnDeleteTask
Public Event OnDisableTask(ByVal TaskID As Integer) Implements
ITaskServer.OnDisableTask
Public Event OnEnableTask(ByVal TaskID As Integer) Implements
ITaskServer.OnEnableTask
Public Event OnNewTask(ByVal TI As TaskInfo) Implements
ITaskServer.OnNewTask
Public Event OnRunTask(ByVal TaskID As Integer) Implements
ITaskServer.OnRunTask
Public Event OnStopTask(ByVal TaskID As Integer) Implements
ITaskServer.OnStopTask
Public Event OnTaskItem(ByVal TIEA As TaskInfoEventArgs) Implements
ITaskServer.OnTaskItem
Public Event OnViewHistory(ByVal THs As TaskHistories) Implements
ITaskServer.OnViewHistory

#Region " ITaskClient"

Public Sub ClearHistory(ByVal TaskID As Integer) Implements
ITaskClient.ClearHistory
RaiseEvent OnClearHistory(TaskID)
End Sub

Public Sub DeleteTask(ByVal TaskID As Integer) Implements
ITaskClient.DeleteTask
RaiseEvent OnDeleteTask(TaskID)
End Sub

Public Sub DisableTask(ByVal TaskID As Integer) Implements
ITaskClient.DisableTask
RaiseEvent OnDisableTask(TaskID)
End Sub

Public Sub EditTaskItem(ByVal TI As TaskInfo) Implements
ITaskClient.EditTaskItem
Dim TIEA As TaskInfoEventArgs
TIEA = New TaskInfoEventArgs(TI)
RaiseEvent OnTaskItem(tiea)
End Sub

Public Sub EnableTask(ByVal TaskID As Integer) Implements
ITaskClient.EnableTask
RaiseEvent OnEnableTask(TaskID)
End Sub

Public Function NewTask(ByVal TI As TaskInfo) As Integer Implements
ITaskClient.NewTask
RaiseEvent OnNewTask(TI)
Return TI.TaskID
End Function

Public Sub RunTask(ByVal TaskID As Integer) Implements ITaskClient.RunTask
RaiseEvent OnRunTask(TaskID)
End Sub

Public Sub StopTask(ByVal TaskID As Integer) Implements
ITaskClient.StopTask
RaiseEvent OnStopTask(TaskID)
End Sub

Public Function TaskItem(ByVal TaskID As Integer) As TaskInfo Implements
ITaskClient.TaskItem
Dim TIEA As TaskInfoEventArgs
TIEA = New TaskInfoEventArgs(TaskID)
RaiseEvent OnTaskItem(TIEA)

Return TIEA.TaskInfo

End Function

Public Function ViewHistory(ByVal TaskID As Integer) As TaskHistories
Implements ITaskClient.ViewHistory
Dim THs As TaskHistories
THs = New TaskHistories(TaskID)
RaiseEvent OnViewHistory(THs)
Return THs
End Function

#End Region

End Class

Assmebly: ClientConsole.exe
'Code truncated for brevity

Public Class ClientConsumer

Private mRemoteService As ITaskClient

Private Delegate Sub ClearHistoryDelegate(ByVal TaskID As Integer)
Private Delegate Function NewTaskDelegate(ByVal TaskInfo As TaskInfo) As
Integer

Public Sub New()
Dim ServerPort As Integer = 5555
ChannelServices.RegisterChannel(New TcpChannel)
mRemoteService =
Activator.GetObject(GetType(SericeRemoting.Remoted Object),
String.Format("tcp://localhost:{0}/RemotedObject", ServerPort.ToString))
End Sub

Public Sub ClearHistory(ByVal TaskID As Integer)

Dim cb As AsyncCallback = New AsyncCallback(AddressOf ClearHistoryBack)
Dim d As ClearHistoryDelegate = New ClearHistoryDelegate(AddressOf
mRemoteService.ClearHistory)
Dim ar As IAsyncResult = d.BeginInvoke(TaskID, cb, Nothing)

End Sub

Private Sub ClearHistoryBack(ByVal ar As IAsyncResult)
Dim d As ClearHistoryDelegate = CType((CType(ar,
System.runtime.Remoting.Messaging.AsyncResult)).As yncDelegate,
ClearHistoryDelegate)

Try
d.EndInvoke(ar)
Trace.WriteLine("Success for Clear History")
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try

End Sub

Public Function NewTask(ByVal TaskInfo As TaskInfo) As Integer

Dim cb As AsyncCallback = New AsyncCallback(AddressOf NewTaskBack)
Dim d As NewTaskDelegate = New NewTaskDelegate(AddressOf
mRemoteService.NewTask)
Dim ar As IAsyncResult = d.BeginInvoke(TaskInfo, cb, Nothing)

'how do I return the value?

End Function

Public Sub NewTaskBack(ByVal ar As IAsyncResult)

Dim d As NewTaskDelegate = CType((CType(ar,
System.runtime.Remoting.Messaging.AsyncResult)).As yncDelegate,
NewTaskDelegate)

Try
d.EndInvoke(ar)
Trace.WriteLine("Success for new task")
' How do I return the value?
'
'
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try

End Sub

End Class

Jan 16 '06 #1
6 1598
I know you folks are busy making your own dime, but if you could give me
some time I would appreciate it.
Thanks very much.
"AMDRIT" <am****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
Hello folks,

I appologize for the cross post, but I really need an answer on this:

I do not think that I am seeing the whole picture here. I would like to
create a windows service and a management console, using Visual Basic
2003. The windows service part, I think, is easy enough. I am more
concerned with the remoting aspect of the project. Below is the general
idea of my approach, please correct my where I am wrong.

I would really appreciate any assistance on this, thanks.
First, let me ask some questions:

1. Why have I not seen a model that uses Delegate functions, it would
seem to be better than wrapping everything inside eventargs?

2. Must I use events to ask the server for infomation from the client?

3. Must I specify <Serializable()> on all eventargs classes?

4. What precuations must I take to prevent conflicts caused when two
clients ask to modify the same information? Say for example, a request of
the server to modify the same row in a database at the same time.

5. How do I return a value from the server?

For this illustration, lets pretend that I am creating a service that
processes tasks based on a schedule. The service would simple have a loop
that waits for work to be done:
While (Not bStop and not bPause)
'Check for tasks to perform at this time
'Create entry, task starting 'Database Log Entry
'Process the task 'Calls StartTask <-- Invokes Plug-in's Start()
'Create entry, task complete + (success value) 'Success Result is
returned by task object
'Check if task is repeating task 'Read database schedule, to see if
this is a recurring task
'Update next run time/date
Wend

Meanwhile, administrators may wish to interact with the service:

--Run Task
--Cancel Task
--Create Task
--Enable Task
--Disable Task
--Edit Task
--Delete Task
--View Task History
Assmebly: SericeRemoting.dll

Public Interface ITaskServer

Delegate Sub RunTask(ByVal TaskID As Integer)
Event OnRunTask As RunTask

Delegate Sub StopTask(ByVal TaskID As Integer)
Event OnStopTask As StopTask

Delegate Sub NewTask(ByVal TI As TaskInfo)
Event OnNewTask As NewTask

Delegate Sub DeleteTask(ByVal TaskID As Integer)
Event OnDeleteTask As DeleteTask

Delegate Sub DisableTask(ByVal TaskID As Integer)
Event OnDisableTask As DisableTask

Delegate Sub EnableTask(ByVal TaskID As Integer)
Event OnEnableTask As EnableTask

Delegate Sub TaskItem(ByVal TIEA As TaskInfoEventArgs)
Event OnTaskItem As TaskItem

Delegate Sub ClearHistory(ByVal TaskID As Integer)
Event OnClearHistory As ClearHistory

Delegate Sub ViewHistory(ByVal THs As TaskHistories)
Event OnViewHistory As ViewHistory

End Interface

Public Interface ITaskClient

Sub RunTask(ByVal TaskID As Integer)
Sub StopTask(ByVal TaskID As Integer)

Function NewTask(ByVal TI As TaskInfo) As Integer
Sub DeleteTask(ByVal TaskID As Integer)

Sub DisableTask(ByVal TaskID As Integer)
Sub EnableTask(ByVal TaskID As Integer)

Function TaskItem(ByVal TaskID As Integer) As TaskInfo
Sub EditTaskItem(ByVal TI As TaskInfo)

Function ViewHistory(ByVal TaskID As Integer) As TaskHistories
Sub ClearHistory(ByVal TaskID As Integer)

End Interface

Public Class RemotedObject
Implements ITaskServer
Implements ITaskClient

Public Event OnClearHistory(ByVal TaskID As Integer) Implements
ITaskServer.OnClearHistory
Public Event OnDeleteTask(ByVal TaskID As Integer) Implements
ITaskServer.OnDeleteTask
Public Event OnDisableTask(ByVal TaskID As Integer) Implements
ITaskServer.OnDisableTask
Public Event OnEnableTask(ByVal TaskID As Integer) Implements
ITaskServer.OnEnableTask
Public Event OnNewTask(ByVal TI As TaskInfo) Implements
ITaskServer.OnNewTask
Public Event OnRunTask(ByVal TaskID As Integer) Implements
ITaskServer.OnRunTask
Public Event OnStopTask(ByVal TaskID As Integer) Implements
ITaskServer.OnStopTask
Public Event OnTaskItem(ByVal TIEA As TaskInfoEventArgs) Implements
ITaskServer.OnTaskItem
Public Event OnViewHistory(ByVal THs As TaskHistories) Implements
ITaskServer.OnViewHistory

#Region " ITaskClient"

Public Sub ClearHistory(ByVal TaskID As Integer) Implements
ITaskClient.ClearHistory
RaiseEvent OnClearHistory(TaskID)
End Sub

Public Sub DeleteTask(ByVal TaskID As Integer) Implements
ITaskClient.DeleteTask
RaiseEvent OnDeleteTask(TaskID)
End Sub

Public Sub DisableTask(ByVal TaskID As Integer) Implements
ITaskClient.DisableTask
RaiseEvent OnDisableTask(TaskID)
End Sub

Public Sub EditTaskItem(ByVal TI As TaskInfo) Implements
ITaskClient.EditTaskItem
Dim TIEA As TaskInfoEventArgs
TIEA = New TaskInfoEventArgs(TI)
RaiseEvent OnTaskItem(tiea)
End Sub

Public Sub EnableTask(ByVal TaskID As Integer) Implements
ITaskClient.EnableTask
RaiseEvent OnEnableTask(TaskID)
End Sub

Public Function NewTask(ByVal TI As TaskInfo) As Integer Implements
ITaskClient.NewTask
RaiseEvent OnNewTask(TI)
Return TI.TaskID
End Function

Public Sub RunTask(ByVal TaskID As Integer) Implements
ITaskClient.RunTask
RaiseEvent OnRunTask(TaskID)
End Sub

Public Sub StopTask(ByVal TaskID As Integer) Implements
ITaskClient.StopTask
RaiseEvent OnStopTask(TaskID)
End Sub

Public Function TaskItem(ByVal TaskID As Integer) As TaskInfo Implements
ITaskClient.TaskItem
Dim TIEA As TaskInfoEventArgs
TIEA = New TaskInfoEventArgs(TaskID)
RaiseEvent OnTaskItem(TIEA)

Return TIEA.TaskInfo

End Function

Public Function ViewHistory(ByVal TaskID As Integer) As TaskHistories
Implements ITaskClient.ViewHistory
Dim THs As TaskHistories
THs = New TaskHistories(TaskID)
RaiseEvent OnViewHistory(THs)
Return THs
End Function

#End Region

End Class

Assmebly: ClientConsole.exe
'Code truncated for brevity

Public Class ClientConsumer

Private mRemoteService As ITaskClient

Private Delegate Sub ClearHistoryDelegate(ByVal TaskID As Integer)
Private Delegate Function NewTaskDelegate(ByVal TaskInfo As TaskInfo) As
Integer

Public Sub New()
Dim ServerPort As Integer = 5555
ChannelServices.RegisterChannel(New TcpChannel)
mRemoteService =
Activator.GetObject(GetType(SericeRemoting.Remoted Object),
String.Format("tcp://localhost:{0}/RemotedObject", ServerPort.ToString))
End Sub

Public Sub ClearHistory(ByVal TaskID As Integer)

Dim cb As AsyncCallback = New AsyncCallback(AddressOf ClearHistoryBack)
Dim d As ClearHistoryDelegate = New ClearHistoryDelegate(AddressOf
mRemoteService.ClearHistory)
Dim ar As IAsyncResult = d.BeginInvoke(TaskID, cb, Nothing)

End Sub

Private Sub ClearHistoryBack(ByVal ar As IAsyncResult)
Dim d As ClearHistoryDelegate = CType((CType(ar,
System.runtime.Remoting.Messaging.AsyncResult)).As yncDelegate,
ClearHistoryDelegate)

Try
d.EndInvoke(ar)
Trace.WriteLine("Success for Clear History")
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try

End Sub

Public Function NewTask(ByVal TaskInfo As TaskInfo) As Integer

Dim cb As AsyncCallback = New AsyncCallback(AddressOf NewTaskBack)
Dim d As NewTaskDelegate = New NewTaskDelegate(AddressOf
mRemoteService.NewTask)
Dim ar As IAsyncResult = d.BeginInvoke(TaskInfo, cb, Nothing)

'how do I return the value?

End Function

Public Sub NewTaskBack(ByVal ar As IAsyncResult)

Dim d As NewTaskDelegate = CType((CType(ar,
System.runtime.Remoting.Messaging.AsyncResult)).As yncDelegate,
NewTaskDelegate)

Try
d.EndInvoke(ar)
Trace.WriteLine("Success for new task")
' How do I return the value?
'
'
Catch ex As Exception
Trace.WriteLine(ex.ToString)
End Try

End Sub

End Class


Jan 16 '06 #2
"AMDRIT" <am****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
I do not think that I am seeing the whole picture here. I would like to
create a windows service and a management console, using Visual Basic
2003. The windows service part, I think, is easy enough. I am more
concerned with the remoting aspect of the project.


OK I saw your plea...

One approach is to create a singleton object on the server that is exposed
via Remoting. It is this object that is used to interact with the service.

Assuming that the service is running, a Remoting client then attaches to the
singleton to access its methods and properties. If you desire to receive
events from the service (via the singleton), the roles are swapped and the
client that receives the event becomes the server in that scenario, and the
service becomes the client. It's somewhat confusing and has ramifications
on where your interface is defined (should be in a separate shared
assembly).

Let me know if you have specific questions about this approach. I'm sorry I
did not take the time to study your source code that you posted.

-- Alan
Jan 16 '06 #3
Thank you for the response.

I have amended my code to speak directly with the issues that concern me the
most.

First I have made this a synchronous sample, I will get to async when I am
ready. I have much to learn first. I am striving towards a solution where
the client requests updates and illicites responses, I do not plan to have
the server push anything unsolicited to the client.

The remoted object has two methods
Sub Announce(Message as string)
Function Add(Int1 as integer, Int2 as integer) as integer

The client will ask for the server to announce a message or add two integers

The server will trace.writeline a message from OnAnnounce event
The server will Return the sum of the OnAdd event

Questions

1. Does the following code speak to your outline of client side requests.
2. How am I to properly clean up the remoted object on both the client and
server.
3. How many concurrent connections does this model support. (3.b I only
plan to need 2, but how will I know what I have?)
4. Do I have to do anything with lifetime tickets?
5. Am I supposed to use eventargs each time I pass data in a method or
function
7. If I have 2 connections attempting to modify a server side value, do I
simply use sync lock, or does it inherently queue requests.
8. Is it possible for the client to time out on a request, can I set the
value or capture the exception?

I think this would be enough to get me going.

'Singleton object that is stored in a common assembly
Class MySingleton
Inherits MarshalByRefObject

Public Event OnAnnounce(ByVal Message As String)
Public Event OnAdd(ByVal e As MathAddArgs)

Public Sub Announce(ByVal Message As String)
RaiseEvent OnAnnounce(Message)
End Sub

Public Function Add(ByVal Int1 As Integer, ByVal Int2 As Integer) As
Integer
Dim e As MathAddArgs

e = New MathAddArgs(Int1, Int2)
RaiseEvent OnAdd(e)

Return e.Sum

End Function

End Class

'Event arguments for adding two integers
'part of the shared assembly
<Serializable()>Public Class MathAddArgs
Inherits System.EventArgs

Private mint1 As Integer
Private mint2 As Integer

Private msum As Integer

Public Sub New(ByVal Int1 As Integer, ByVal Int2 As Integer)
mint1 = Int1
mint2 = Int2
End Sub

Public ReadOnly Property Int1() As Integer
Get
Return mint1
End Get
End Property

Public ReadOnly Property Int2() As Integer
Get
Return mint2
End Get
End Property

Public ReadOnly Property Sum() As Integer
Get
Return msum
End Get
End Property

Public Sub SetSum(ByVal Value As Integer)
msum = Value
End Sub

End Class

'Client Assembly, interacts with the service via MySingleton
Class TestClient

Private mRemoted As MySingleton

Public Sub New()
ChannelServices.RegisterChannel(New TcpChannel)
mRemoted = Activator.GetObject(GetType(MySingleton),
"tcp://myserver:8084/MySingleton")
End Sub

Public Function ServerAdd(ByVal int1 As Integer, ByVal Int2 As Integer) As
Integer
Return mRemoted.Add(int1, Int2)
End Function

Public Sub ServerAnnounce(ByVal Message As String)
mRemoted.Announce(Message)
End Sub

Protected Overrides Sub Finalize()
mRemoted = Nothing
MyBase.Finalize()
End Sub
End Class

'Performs methods and functions based on calls from the client via
MySingleton
Class TestService

Private mRemoted As MySingleton

Public Sub New()
Dim refClient As ObjRef

ChannelServices.RegisterChannel(New TcpChannel(8084))
mRemoted = New MySingleton

refClient = RemotingServices.Marshal(mRemoted, "MySingleton")

AddHandler mRemoted.OnAdd, AddressOf Singleton_Add
AddHandler mRemoted.OnAnnounce, AddressOf Singleton_Announce
End Sub

Private Sub Singleton_Add(ByVal e As MathAddArgs)
e.SetSum(e.Int1 + e.Int2)
End Sub

Private Sub Singleton_Announce(ByVal Message As String)
Trace.WriteLine(String.Format("message from some client is: {0}",
Message))
End Sub

Protected Overrides Sub Finalize()

RemoveHandler mRemoted.OnAdd, AddressOf Singleton_Add
RemoveHandler mRemoted.OnAnnounce, AddressOf Singleton_Announce

MyBase.Finalize()

End Sub
End Class
"Alan Pretre" <no@spam> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
"AMDRIT" <am****@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
I do not think that I am seeing the whole picture here. I would like to
create a windows service and a management console, using Visual Basic
2003. The windows service part, I think, is easy enough. I am more
concerned with the remoting aspect of the project.


OK I saw your plea...

One approach is to create a singleton object on the server that is exposed
via Remoting. It is this object that is used to interact with the
service.

Assuming that the service is running, a Remoting client then attaches to
the singleton to access its methods and properties. If you desire to
receive events from the service (via the singleton), the roles are swapped
and the client that receives the event becomes the server in that
scenario, and the service becomes the client. It's somewhat confusing and
has ramifications on where your interface is defined (should be in a
separate shared assembly).

Let me know if you have specific questions about this approach. I'm sorry
I did not take the time to study your source code that you posted.

-- Alan

Jan 16 '06 #4
"AMDRIT" <am****@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP14.phx.gbl...
1. Does the following code speak to your outline of client side requests.
Before we get too far, the service's OnStart() routine is the one that
should register and instantiate the singleton, using
System.Runtime.Remoting.RemotingConfiguration.Regi sterWellKnownServiceType(),
and System.Activator.GetObject().

There is no need to use events/eventargs as you show in your code. Simply
expose public methods and properties in the singleton.
2. How am I to properly clean up the remoted object on both the client
and server.
If you make the singleton a component, by deriving it from
System.ComponentModel.Component, you can supply a Dispose() routine that can
be called from the service's OnStop(). This will also give you a canvas for
dropping on other components in VS such as timers, etc.
3. How many concurrent connections does this model support. (3.b I only
plan to need 2, but how will I know what I have?)
Should be OK. Haven't actually tested this myself.
4. Do I have to do anything with lifetime tickets?
If your singleton is a component, then you can override the
InitializeLifetimeServices() method to setup the lifetime as needed.
Returning null will have infinite lifetime.
5. Am I supposed to use eventargs each time I pass data in a method or
function
Not needed. See above.
7. If I have 2 connections attempting to modify a server side value, do I
simply use sync lock, or does it inherently queue requests.
Yes, you will need to synchronize access.
8. Is it possible for the client to time out on a request, can I set the
value or capture the exception?


Yes, you must be able to handle Remoting exceptions in all calls through the
Remoting proxy.

-- Alan
Jan 16 '06 #5
Alan,

Thank you for the responses, I really do appreciate it. I do have a follow
up question though; if I derive this from System.ComponentModel.Component,
how can I also inherit MarshalByRefObj?
"Alan Pretre" <no@spam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"AMDRIT" <am****@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP14.phx.gbl...
1. Does the following code speak to your outline of client side
requests.


Before we get too far, the service's OnStart() routine is the one that
should register and instantiate the singleton, using
System.Runtime.Remoting.RemotingConfiguration.Regi sterWellKnownServiceType(),
and System.Activator.GetObject().

There is no need to use events/eventargs as you show in your code. Simply
expose public methods and properties in the singleton.
2. How am I to properly clean up the remoted object on both the client
and server.


If you make the singleton a component, by deriving it from
System.ComponentModel.Component, you can supply a Dispose() routine that
can be called from the service's OnStop(). This will also give you a
canvas for dropping on other components in VS such as timers, etc.
3. How many concurrent connections does this model support. (3.b I only
plan to need 2, but how will I know what I have?)


Should be OK. Haven't actually tested this myself.
4. Do I have to do anything with lifetime tickets?


If your singleton is a component, then you can override the
InitializeLifetimeServices() method to setup the lifetime as needed.
Returning null will have infinite lifetime.
5. Am I supposed to use eventargs each time I pass data in a method or
function


Not needed. See above.
7. If I have 2 connections attempting to modify a server side value, do
I simply use sync lock, or does it inherently queue requests.


Yes, you will need to synchronize access.
8. Is it possible for the client to time out on a request, can I set the
value or capture the exception?


Yes, you must be able to handle Remoting exceptions in all calls through
the Remoting proxy.

-- Alan

Jan 17 '06 #6
"AMDRIT" <am****@hotmail.com> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
if I derive this from System.ComponentModel.Component, how can I also
inherit MarshalByRefObj?


Ah. A Component is a MBR object!

See:
http://msdn.microsoft.com/library/de...classtopic.asp

-- Alan
Jan 17 '06 #7

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

Similar topics

0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS...
5
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS...
0
by: Martijn Damen | last post by:
Hi, At the moment I am trying to develop an application that uses another app over .net remoting and having some problems with it (ok, that is ofcourse why I am here), hope somebody can shine a...
8
by: Raju Joseph | last post by:
Hi All, I am just trying to get an opinion here. I know this is always a tough choice to make. We are in the process of converting our VB6 based Healthcare Information System (a full-fledged...
1
by: test.file | last post by:
I'd like to implement QueueUserWorkItem for some parts of the app; specifically for DB related caching and file i/o. Example: When the user finishes work on a file, I'd like to process the file...
6
by: AMDRIT | last post by:
Hello folks, I appologize for the cross post, but I really need an answer on this: I do not think that I am seeing the whole picture here. I would like to create a windows service and a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.