Pseudonymous
Pseudonymous

Reputation: 894

Listening for property value change in third-party .NET library

I am consuming a third-party library in my .NET C# application. Essentially, the library exposes one method and one property; a pared-down representation of the interface I'm working is:

public interface IDisconnect
{
    bool IsDisconnected { get; }

    void Disconnect();
}

At some point after calling the method Disconnect(), when the disconnect operation completes, the property IsDisconnected gets set to true. The third-party developer would have made things a lot easier if they'd implemented a OnDisconnectComplete event (or similar) for me to subscribe to, but, given that they haven't, are there any elegant ways to listen for a property change in a third-party libraries built in to the .NET framework?

Upvotes: 0

Views: 400

Answers (1)

Divisadero
Divisadero

Reputation: 913

From the information provided there is one very ugly solution, to create notifier class which will get the instance of IDisconnect. Here, you can set the timer to regularly check the value of IsDisconnected and if it changes, raise the event for the IDisconnnect itself. Timer setting is up to you.

Upvotes: 1

Related Questions