NetMq.cs 783 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using GSG.NET.Concurrent;
  2. using NetMQ;
  3. using NetMQ.Sockets;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace OHVLoggerTest
  10. {
  11. public class NetMq
  12. {
  13. PublisherSocket pub = null;
  14. ThreadCancel threadCancel = new ThreadCancel();
  15. public NetMq()
  16. {
  17. pub = new PublisherSocket();
  18. pub.Bind( "tcp://127.0.0.1:5565" );
  19. threadCancel.AddGo( Th_Pub );
  20. }
  21. void Th_Pub()
  22. {
  23. while ( !this.threadCancel.Canceled )
  24. {
  25. LockUtils.Wait( 1000 );
  26. this.pub.SendMoreFrame( "1000" ).SendFrame( "Test" );
  27. LockUtils.Wait( 100 );
  28. }
  29. }
  30. }
  31. }