0

无法使用 (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();

它不去 StopAllThread = true;

4

1 回答 1

1

就用这个...

context.Terminate()
于 2013-06-14T23:54:52.993 回答