Add ErrorChanged event to propagate DataStream exceptions

This commit is contained in:
John Colvin committed 2024-09-22 18:46:10 +00:00
1 parent a1caaf9c07
commit 30636606a0
4 files changed
+93 -18

No files matched your search

@@ -32,6 +32,9 @@ namespace BCG
public DataStream (DataStream realSource)
{
myRealSource = realSource;
if (myRealSource is not null) {
myRealSource.ErrorChanged += OnError;
}
myOnChangeDelegate = null;
myPendingAdds = new Stack();
}
@@ -48,6 +51,8 @@ namespace BCG
}
}
public event Action<Exception> ErrorChanged;
public delegate void ChangeDelegate(object newValue);
public event ChangeDelegate onChange
{
@@ -120,8 +125,15 @@ namespace BCG
protected virtual object myGetValueForInitialSubscription()
{return myLastValue;}
protected void mySetRealSource (DataStream src)
{myRealSource = src;}
protected void mySetRealSource (DataStream src) {
if (myRealSource is not null) {
myRealSource.ErrorChanged -= OnError;
}
myRealSource = src;
if (myRealSource is not null) {
myRealSource.ErrorChanged += OnError;
}
}
protected virtual void myOnFirstSubscriber() {myFirstSubImplemented = false;}
protected virtual void myOnLastSubscriber () {myLastSubImplemented = false;}
@@ -143,6 +155,10 @@ namespace BCG
}
}
protected void OnError(Exception error) {
ErrorChanged?.Invoke(error);
}
public Guid ID
{
get