如何在c#中使用zeromq后终止上下文
本文关键字:zeromq 终止 上下文 | 更新日期: 2023-09-27 18:18:13
不能出去使用(var context = new context(1)){},如何终止它
python有context.term(),但是c#没有!
using (var context = new Context(1))
{
//using (Socket server = context.Socket(SocketType.REQ))
using (Socket server = context.Socket(SocketType.PUB))
{
var serializer = new VpfsLiveFeed.MessageTypes.JsonSerializer();
var jsonMessage = new VpfsLiveFeed.MessageTypes.LivefeedEnvelope
{
Message = new VpfsLiveFeed.MessageTypes.LivefeedMessage
{
MessageType = "TERMINATION_REQUEST",
MessageId = "Testing Message",
ReplyEmailAddress = "VPLAB@localhost.com"
}
};
server.Connect(string.Format("tcp://{0}", ConfigurationManager.AppSettings["termination_host"]));
server.Send(serializer.MessageToBytes<VpfsLiveFeed.MessageTypes.LivefeedEnvelope>(jsonMessage), Encoding.UTF8);
server.Dispose();
}
context.Dispose(); // stop here is not go out of this {}
}
StopAllThread = true;
System.Console.WriteLine("Stopped");
if (myHost != null)
myHost.Close();
就用这个…
context.Terminate()