|
1 |
| -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.Diagnostics;
|
@@ -39,9 +39,9 @@ public sealed class NetMQPoller :
|
39 | 39 | private readonly StopSignaler m_stopSignaler = new StopSignaler();
|
40 | 40 |
|
41 | 41 | private NetMQSelector.Item[]? m_pollSet;
|
42 |
| - private NetMQSocket[]? m_pollact; |
| 42 | + private NetMQSocket[]? m_pollact; |
43 | 43 |
|
44 |
| - private volatile bool m_isPollSetDirty = true; |
| 44 | + private volatile bool m_isPollSetDirty = true; |
45 | 45 | private int m_disposeState = (int)DisposeState.Undisposed;
|
46 | 46 |
|
47 | 47 | #if NET35
|
@@ -354,7 +354,7 @@ public void Remove(Socket socket)
|
354 | 354 |
|
355 | 355 | #region Contains
|
356 | 356 | #if !NET35
|
357 |
| - |
| 357 | + |
358 | 358 | /// <summary>
|
359 | 359 | /// Check if poller contains the socket asynchronously.
|
360 | 360 | /// </summary>
|
@@ -425,12 +425,27 @@ public void RunAsync()
|
425 | 425 | /// </summary>
|
426 | 426 | /// <param name="threadName">The thread name to use.</param>
|
427 | 427 | public void RunAsync(string threadName)
|
| 428 | + { |
| 429 | + RunAsync(threadName, false); |
| 430 | + } |
| 431 | + |
| 432 | + /// <summary> |
| 433 | + /// Runs the poller in a specified thread - background/foreground, returning once the poller has started. |
| 434 | + /// </summary> |
| 435 | + /// <param name="threadName">The thread name to use.</param> |
| 436 | + /// <param name="isBackgroundThread">Allow the poller thread to be a long running |
| 437 | + /// poller (either foreground thread/background)</param> |
| 438 | + public void RunAsync(string threadName, bool isBackgroundThread) |
428 | 439 | {
|
429 | 440 | CheckDisposed();
|
430 | 441 | if (IsRunning)
|
431 | 442 | throw new InvalidOperationException("NetMQPoller is already running");
|
432 | 443 |
|
433 |
| - var thread = new Thread(Run) { Name = threadName }; |
| 444 | + var thread = new Thread(Run) |
| 445 | + { |
| 446 | + Name = threadName, |
| 447 | + IsBackground = isBackgroundThread |
| 448 | + }; |
434 | 449 | thread.Start();
|
435 | 450 |
|
436 | 451 | m_switch.WaitForOn();
|
@@ -473,8 +488,8 @@ public void Run()
|
473 | 488 | /// Runs the poller on the caller's thread. Only returns when <see cref="Stop" /> or <see cref="StopAsync" /> are called from another thread.
|
474 | 489 | /// </summary>
|
475 | 490 | /// <param name="syncContext">The synchronization context that will be used.</param>
|
476 |
| - public void Run(SynchronizationContext syncContext) |
477 |
| - { |
| 491 | + public void Run(SynchronizationContext syncContext) |
| 492 | + { |
478 | 493 | if (syncContext == null)
|
479 | 494 | throw new ArgumentNullException("Must supply a Synchronization Context");
|
480 | 495 |
|
|
0 commit comments