Skip to content

Commit 7db326c

Browse files
committed
Fix CS0170
1 parent 5e08697 commit 7db326c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/NetMQ/AsyncReceiveExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public static async Task<NetMQMessage> ReceiveMultipartMessageAsync(
8585
}
8686

8787
TaskCompletionSource<(byte[], bool)> source = new TaskCompletionSource<(byte[], bool)>();
88-
var registration = cancellationToken.Register(PropagateCancel);
88+
CancellationTokenRegistration? registration = null;
89+
registration = cancellationToken.Register(PropagateCancel);
8990

9091
void Listener(object sender, NetMQSocketEventArgs args)
9192
{
@@ -96,15 +97,15 @@ void Listener(object sender, NetMQSocketEventArgs args)
9697
msg.Close();
9798

9899
socket.ReceiveReady -= Listener;
99-
registration.Dispose();
100+
registration?.Dispose();
100101
source.TrySetResult((data, more));
101102
}
102103
}
103104

104105
void PropagateCancel()
105106
{
106107
socket.ReceiveReady -= Listener;
107-
registration.Dispose();
108+
registration?.Dispose();
108109
source.TrySetCanceled();
109110
}
110111

0 commit comments

Comments
 (0)