Re: Windows service talking to a Windows Application



WinDev,

That's why I recommended what I did with the interface. Going into more
detail, you would create an interface that exists outside of the client and
server assemblies, like this:

public interface ICallback
{
void DataUpdated(DataSet ds);
}

I'm using a data set here, but you can use anything.

Then, in the client, you would create a class that derives from
MarshalByRefObject which implements this interface.

On the server, you would expos a method which take a parameter of this
interface type.

Then, when your client starts up, you will call the method in the server
which takes an instance of the ICallback interface (or whatever you name it)
and then pass the instance of your object on the client side. The server
will get a proxy to the client, which it can then call into to notify it of
the "update".

Of course, the client on the object can also expose methods and whatnot,
or have a reference to the UI, whatever you need to perform your update of
the data.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"WinDev" <WinDev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:597D0D5D-9095-4670-BA91-E1375995221B@xxxxxxxxxxxxxxxx
> Nicholas,
> Let me try again explaining what I want to do.
>
> I have a service that is running that every once in a while goes out to a
> database and does some calculations. I then have a Windows App that
> displays
> the calculations. So I have my Windows service as a client of the windows
> app. The service can call a method in the app (and that works fine) but I
> can't figure out how to tell the win app that there's new data.
>
> So here's a full outline of what I would like it to do:
>
> Win App is up and going and dispays whatever.
> Win Service starts up.
> At some point the Win Service creates some new calculations.
> Win Service wants to send some kind of notification (and results of the
> calculations if possible) to the win app program.
> Win App displays the new statistics.
>
> I've got the win app program working. I've got the win service working. I
> have the win service making a call to a routine in the win app program.
> But I
> can't figure out what to do in the client so that it knows about the new
> data. I can pass the new data in to a routine in the called routine but
> then
> what do I do with it? How does the win app program know about the new
> data?
>
> Thanks.
>
> Jeff.
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Jeff,
>>
>> Well, what does your service do now then? I mean, it's running, and
>> that's great, but it has to do something. When your object that is being
>> remoted is hosted in your service gets a call through a method, that is
>> your
>> opportunity to perform work. You are able to send back data in the form
>> of
>> output parameters and return values.
>>
>> Now, are you saying that you want to just call methods on the client
>> from the service? If that is the case, then you need an object on the
>> client which derives from MarshalByRefObject. You also need an interface
>> that is shared between the client and the service which exposes the
>> methods
>> the service can call on the client.
>>
>> When the client first connects to the service, you can pass the
>> implementation of this interface to the service, and the service can
>> store a
>> reference to it. Because the object passed to the service derives from
>> MarshalByRefObject, the service will hold a proxy to the client, instead
>> of
>> a serialized instance.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>> "WinDev" <WinDev@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:7F2810AA-8C87-4897-AF39-680595A34D43@xxxxxxxxxxxxxxxx
>> > We are trying to build a system where we have a Windows Service do some
>> > manipulation of data, and then sending the data to a Windows App. I had
>> > posted a question of how we should do this and was told remoting was
>> > the
>> > way
>> > to go.
>> >
>> > So I got a client and a server program up and going and from the client
>> > I
>> > can call a routine in the server program. I can't figure out how to
>> > actually
>> > send data to the client. At the moment the client calls a routine that
>> > returns the time from the server (it's a stupid program but it proves
>> > it
>> > works.) But what I want to do is send a dataset to the server and then
>> > have
>> > the server do some processing on the dataset. I can figure out how to
>> > send
>> > the dataset but what do I do at that point? I need to tell the server
>> > that
>> > it
>> > has new data to process.
>> >
>> > Anybody have any ideas on how to get this to work?
>> >
>> > Thanks for your help.
>> >
>> > Jeff.
>>
>>
>>


.



Relevant Pages

  • Re: What doesnt lend itself to OO?
    ... >>server is a pure data transfer interface. ... essentially exposing the client or service implementation. ... >>paradigms can be abstracted just like any other problem space in an OO ...
    (comp.object)
  • Re: What doesnt lend itself to OO?
    ... The whole idea that a subsystem is just ... > The first line exists in the server. ... objects between client and server i.e. as far as the client code is ... > external interface is the traditional input interface whose ...
    (comp.object)
  • Re: What doesnt lend itself to OO?
    ... >> The problem with stateless programming is that it turns object ... > server is a pure data transfer interface. ... So the client should be ...
    (comp.object)
  • RE: Using kerberosSecurity Throws Security Exception
    ... I am experiencing this error while trying to use a Windows XP client ... application to access a web service located on a W2k3 server. ... client app on the server, ... > Account with a Custom Principal Name using SetSPN.exe utility. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Questions about Remoting, objects, threading. lease lifetime and object cleanup, and a couple of
    ... so long as the Client app is ... always refering to the same server object. ... it sets its ClassOne object to nothing and goes away. ... >>The client app at some point is going to become an ASP.Net app also. ...
    (microsoft.public.dotnet.framework.remoting)

Quantcast