Reputation: 668
How expensive is ZmqContext.Create() and zmqContext.CreateSocket(SocketType.PUB) calls when using ZeroMQ in C# - I'm using ZeroMQ 3.2.x for .NET 4.0?
I need my ZeroMQ Socket setup and bound (bind) right on form load because I will always have at least one ZeroMQ Subscriber connected. Almost all the ZeroMQ examples wrap the Context Create and Socket Create in a "using" statement that I have seen.
Do I need to worry about tear down (close and dispose) if I don't use the "using" method when the process terminates? I don't know that I can guarantee that my _FormClosing or _FormClosed will be hit since there is no Close box on this Win Form App it is terminated by another application if it needs to be. This Win Form app Publisher generally runs 24x7 with a listening app that runs 24x7.
Upvotes: 3
Views: 538
Reputation: 6669
In general when you want to know the cost of some operation, just write a small program that does it 1000, 10K, 100K, 1M times, and measure the time it takes to run.
Your specific question is a little special because even if these operations cost nothing, you might run out of file handles if you open and close them too often.
Most likely your use case will work fine but you'll want to stress it to be sure if and where it breaks.
Upvotes: 2