diff --git a/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs b/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs index 2e735d5..869d135 100644 --- a/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs +++ b/Capnp.Net.Runtime/Rpc/TcpRpcClient.cs @@ -274,7 +274,7 @@ namespace Capnp.Rpc /// /// State of Connection has changed /// - public event EventHandler ConnectionStateChanged; + public event EventHandler? ConnectionStateChanged; private ConnectionState _State = ConnectionState.Initializing; @@ -295,13 +295,9 @@ namespace Capnp.Rpc }; _State = value; - EventHandler eventHandler = ConnectionStateChanged; - if(eventHandler != null) - { - eventHandler(this, args); - } + ConnectionStateChanged?.Invoke(this, args); } - } + } /// /// Gets the number of RPC protocol messages sent by this client so far.