473,396 Members | 1,998 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,396 software developers and data experts.

Windows Services + Remoting

greetings,

I've created a service that is being used as a server, basically i have 1
DLL, one service and one client.

I'm using TcpChannel to talk to the server, so I call the functions directly
from the client to the server.

Now I have a long process that the server will deal when the client
request... is there a way to keep the client informed about the progress?
I wanted to implement a progress bar with percentage, but all the values I
can get is the return of a function on the server....

How can I workaround this problem?
May 2 '07 #1
2 1553
Diogo,

The best way to do this would be to create an interface in a separate
assembly that defines the callback into the client. Something like:

public interface IProgressNotification
{
void ProgressChanged(string identifier, int numberProcessed, int total);
}

Or something to that effect, which will notify you of the current
progress (and any other information you need).

You would also have a class which implements this interface in the same
assembly, which implements this interface. The class MUST derive from
MarshalByRefObject. It also exposes events which have the same signature as
the interface (or maybe not, but the events should be able to be mapped from
the interface methods to the events being fired). When the interface
methods are called, you fire the appropriate events.

You would reference this in the server and the client.

On the service, you would take an extra parameter of the interface type.
On the client, you would pass an instance of this class to the initial call.
Before you pass the class, you would sign up for the events on the class.

Then, on the server, call the methods on the interface. Because the
interface implementation derives from MarshalByRefObject, the call will be
made back into the app domain of the client, and then the event will fire,
and you can take the appropriate action.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Diogo Alves - Software Developer" <Diogo Al***@discussions.microsoft.com>
wrote in message news:D8**********************************@microsof t.com...
greetings,

I've created a service that is being used as a server, basically i have 1
DLL, one service and one client.

I'm using TcpChannel to talk to the server, so I call the functions
directly
from the client to the server.

Now I have a long process that the server will deal when the client
request... is there a way to keep the client informed about the progress?
I wanted to implement a progress bar with percentage, but all the values I
can get is the return of a function on the server....

How can I workaround this problem?

May 2 '07 #2
Greeting Nicholas,

Thanks for your answer but I'm pretty new in this stuff....

I already have a class that inherits the MArshalByRefObject
and I use it to get answers from the server like this:
On the client windows form I have:

public ServerComm.Server obj = new ServerComm.Server();
public TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
obj =
(ServerComm.Server)Activator.GetObject(typeof(Serv erComm.Server),
"tcp://n5dalves:50050/RemoteServer");

then I call
obj.GetServerMAchineName();

in the inherited class I have this:

public string GetMachineName()
{
return System.Environment.MachineName ;
}
The problem is that I only get a return at the time...

if the server is processing I would like it to return the progress to the
client...
may you write an example

I'm pretty confused with this :S

"Nicholas Paldino [.NET/C# MVP]" wrote:
Diogo,

The best way to do this would be to create an interface in a separate
assembly that defines the callback into the client. Something like:

public interface IProgressNotification
{
void ProgressChanged(string identifier, int numberProcessed, int total);
}

Or something to that effect, which will notify you of the current
progress (and any other information you need).

You would also have a class which implements this interface in the same
assembly, which implements this interface. The class MUST derive from
MarshalByRefObject. It also exposes events which have the same signature as
the interface (or maybe not, but the events should be able to be mapped from
the interface methods to the events being fired). When the interface
methods are called, you fire the appropriate events.

You would reference this in the server and the client.

On the service, you would take an extra parameter of the interface type.
On the client, you would pass an instance of this class to the initial call.
Before you pass the class, you would sign up for the events on the class.

Then, on the server, call the methods on the interface. Because the
interface implementation derives from MarshalByRefObject, the call will be
made back into the app domain of the client, and then the event will fire,
and you can take the appropriate action.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Diogo Alves - Software Developer" <Diogo Al***@discussions.microsoft.com>
wrote in message news:D8**********************************@microsof t.com...
greetings,

I've created a service that is being used as a server, basically i have 1
DLL, one service and one client.

I'm using TcpChannel to talk to the server, so I call the functions
directly
from the client to the server.

Now I have a long process that the server will deal when the client
request... is there a way to keep the client informed about the progress?
I wanted to implement a progress bar with percentage, but all the values I
can get is the return of a function on the server....

How can I workaround this problem?


May 2 '07 #3

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

Similar topics

11
by: Michael Riggio | last post by:
Is there a way to have a windows service instantiate a class that is a web service, which will then be accessible to clients via HTTP? Thanks, -Mike
0
by: Ashish | last post by:
Hi All, If I use windows services to host a singleton server activated remoting objects. Then my guesses are: 1. I can create an asp.net application that internally use these objects. 2. Two...
20
by: Moty Michaely | last post by:
Hello, Can anyone please help me finding a good way to develop a c# winforms application client for a pre-developed windows service? Should I use wse2 with tcp protocol? Bu I still have win98...
1
by: Nick | last post by:
hi, all What is the difference between C# windows Services and web services in vs.net? Becuase I have a windows services using http remoting, and client access it by a http url address, so it...
5
by: Brian Patrick | last post by:
I have an application model which will consist of a front-end configuration application, which needs to control the state of a back-end vb.net windows service (which is the component that does all...
3
by: Rob | last post by:
Can a form be opened from a Windows service? I have a windows service that I would like to open a form from a notify icon. I cannot get the Notify Icon to display nor can I open a form. Any...
1
by: Patrick | last post by:
With VS.NET Standard (not VS.NET Professional). Can i develop windows Services with this? Also, can i develop components for .NET Remoting? Currently I develop windows services with my VS.NET...
17
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
2
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app...
2
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.