Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Remoting: Disconnecting an object

I have an object that receives events through remoting.  How can I "disconnect" this object so that the server cannot send any more events to it? (The same effect as closing my client application).
0
eternal_21
Asked:
eternal_21
  • 3
1 Solution
 
eternal_21Author Commented:
I should mention that I am obtaining this object using,

  System.Runtime.Remoting.RemotingServices.Connect(System.Type, System.String).
0
 
AlexFMCommented:
I am not sure whether this can be applied to remoting, but generally disconnecting from event is done using -= operator. For example, if this code subscribes to some event:

        MouseEventsHandler handler;         // MouseEventsHandler is some delegate

        private void Form1_Load(object sender, System.EventArgs e)
        {
            ...
            // subscribe to m_MouseEvent event
            handler = new MouseEventsHandler(Form1_MouseEvent);   // keep this in class member if I want to unsubscribe later
            m_MessageFilter.m_MouseEvent += handler;
        }

To unsubscribe from this event I can use the following code:

        private void button1_Click(object sender, System.EventArgs e)
        {
            m_MessageFilter.m_MouseEvent -= handler;
        }
0
 
eternal_21Author Commented:
What I am looking for is a way to server the connection between the client and my server without having to unsubscribe to any events that my be in use... I will post some more code tomorrow - thanks for your advice Alex.
0
 
eternal_21Author Commented:
Sorry, AlexFM

This problem has been put on hold.  I will close this question for now, but select your answer as it may help others in the future.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now