[zeromq-dev] .Net Assert Error: Line 93, locator.cpp
Sean McKay
sean at on-track-solutions.com
Fri May 15 01:51:09 CEST 2009
I have attempted to create two Zmq within the same application but on
different threads in .Net, and when I attempt to send, from one thread to
another, I consistently get problems with the assert at line 93. The reason
I'm not trying to use the same Zmq for both threads is that I don't wish to
fish the overhead on the mutex/sync locks I would need to use.
Any advice on resolving this would be appreciated. I have included the
main source.
Thanks,
Sean
private struct QData
{
public int Exchange1;
public int Exchange2;
}
private void btnQer_Click(object sender, EventArgs e)
{
byte[] inMessage;
int type;
int roundtripCount = 5;
int messageSize = 2048;
// Create 0MQ Dnzmq class.
int exchange2;
int exchange;
Zmq qManager = GetQManager(true, out exchange2, out exchange);
//AsyncOperation aoSender =
AsyncOperationManager.CreateOperation(new QData(){Exchange1 =
exchange,Exchange2 = 2});
SendOrPostCallback SendMessages = fxn;
IAsyncResult asyncResult = SendMessages.BeginInvoke(new QData()
{Exchange1 = exchange, Exchange2 = 2}, null,
null);
//aoSender.Post(SendMessages,null );
// Start sending messages.
for (int i = 0; i < roundtripCount; i++)
{
qManager.Receive(out inMessage, out type, true);
Debug.Assert(inMessage.Length == messageSize);
lblStatus.Text = "Iteration " + i + " Received Message: " +
inMessage.Length + " bytes";
statusStrip.Refresh();
}
qManager.Destroy();
}
private void fxn(object o)
{
int messageSize = 2048;
QData data = (QData)o;
int Exchange1 =0;
int Exchange2 =0;
Zmq qSender = GetQManager(false,out Exchange2, out Exchange1);
Exchange1 = data.Exchange1;
Exchange2 = data.Exchange2;
// Create a message to send.
byte[] outMessage = new byte[messageSize];
// Start sending messages.
for (int i = 0; i < 10; i++)
{
qSender.Send(Exchange2, outMessage, true);
Console.WriteLine(i);
}
qSender.Destroy();
}
private Zmq GetQManager(bool shouldCreate,out int exchange2, out int
exchange)
{
string host = "127.0.0.1";
Zmq qManager = new Zmq();
qManager.Open(host);
string SendingExchange1 = "Exchange1";
string SendingExchange2 = "Exchange2";
string ReceivingQueue1 = "Queue1";
string ReceivingQueue2 = "Queue2";
if (shouldCreate)
{
exchange = qManager.CreateExchange(SendingExchange1,
Zmq.SCOPE_GLOBAL, "",
Zmq.STYLE_LOAD_BALANCING);
exchange2 = qManager.CreateExchange(SendingExchange2,
Zmq.SCOPE_GLOBAL, "",
Zmq.STYLE_LOAD_BALANCING);
qManager.CreateQueue(ReceivingQueue1, Zmq.SCOPE_GLOBAL, "",
Zmq.NO_LIMIT, Zmq.NO_LIMIT,
Zmq.NO_SWAP);
qManager.CreateQueue(ReceivingQueue2, Zmq.SCOPE_GLOBAL, "",
Zmq.NO_LIMIT, Zmq.NO_LIMIT,
Zmq.NO_SWAP);
qManager.Bind(SendingExchange1, ReceivingQueue2, null,
null);
qManager.Bind(SendingExchange2, ReceivingQueue1, null,
null);
}
else
{
exchange = 0;
exchange2 = 0;
}
return qManager;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090514/ce159c8c/attachment.htm>
More information about the zeromq-dev
mailing list