Skip to content

Commit e07b1a9

Browse files
Christoph BauerChristoph Bauer
authored andcommitted
NetMQRuntime Null Check for Current
1 parent cb70c8a commit e07b1a9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/NetMQ/NetMQRuntime.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ public NetMQRuntime()
3636
/// </summary>
3737
public static NetMQRuntime Current
3838
{
39-
get { return s_current.Value!; }
39+
get
40+
{
41+
var result = s_current.Value;
42+
if (result == null)
43+
throw new InvalidOperationException("NetMQRuntime.Current is not available on this thread. Ensure that a NetMQRuntime has been created.");
44+
else
45+
return result;
46+
}
4047
}
4148

4249
internal static NetMQPoller Poller
@@ -52,7 +59,7 @@ public void Run(params Task[] tasks)
5259
{
5360
Run(CancellationToken.None, tasks);
5461
}
55-
62+
5663
internal void Add(NetMQSocket socket)
5764
{
5865
m_poller.Add(socket);

0 commit comments

Comments
 (0)