开发者

Raising events from WCF service to consuming dll

Hi

Though it's a simple thing, I don't know how to do it.

I'm trying to sign the dll to events happening on the server side.

the clients has an instance of this dll and they have to receive notifications from the server.

on the service I defined (c#):

public delegate ActionResult ActionComplitedHandler(object sender,ActionComplitedEventArgs e);

.

public event ActionComplitedHandler ActionComplited;

        public void OnActionComplited(ActionResult actionResult)
        {
            if (ActionComplited != null)
            {
                ActionComplitedEventArgs args = new ActionComplitedEventArgs();
                args.ActionResult = actionResult;
                ActionComplited(this, args);
            }
    }

But when trying to sign the dll to开发者_开发知识库 the event I cant's see it.

mySeriveInstance.ActionComplited+=... //(I don't get the eventHandler after the dot)

I prefer not to use WCF callback.

The WCF service instance is Single.

What do I do wrong and is there other method to do that?

Thanks.


There are two basic ways you can do this:

1.) You can self-host a WCF service in your client application, and in the call to your server pass in the ip address of the client machine. The server can then construct a proxy and call back to the client when it wants to send it an event

2.) You can poll for events from the server every so often. Give every client an identifier in their service response, and then they can call the server with that identifier every so often. You can use caching on the server side to store a list of undelivered events, and then when a client hits that link you return the oldest event for the client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜