// Callback from "libICE" to process a message. private void ProcessMessage (IntPtr iceConn, IntPtr clientData, Xlib.Xint opcode, Xlib.Xulong length, XBool swap, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet) { bool haveReply; if (messageTransaction) { throw new XInvalidOperationException("Attempt to process message in the middle of sending another one"); // I always wondered, what will happen if we throw exception from callback? :) } this.messageTransaction = true; this.messageLength = (int)length; // Process the message. try { replyWait = replyWait; haveReply = true; replyReadyRet = ProcessMessage((int)opcode, replyWait.reply) ? XBool.True:XBool.False; // We omit `swap' here, can one need it? Even theoretrically?.. } catch (NullReferenceException) { haveReply = false; replyReadyRet = ProcessMessage((int)opcode) ? XBool.True:XBool.False; } this.messageTransaction = false; }
extern public static Xlib.Xint IceProcessMessages (IceConn *iceConn, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet);
// Callback from "libICE" to process a message. private void ProcessMessage (IntPtr iceConn, IntPtr clientData, Xlib.Xint opcode, Xlib.Xulong length, XBool swap, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet) { bool haveReply; if(messageTransaction) { throw new XInvalidOperationException("Attempt to process message in the middle of sending another one"); // I always wondered, what will happen if we throw exception from callback? :) } this.messageTransaction = true; this.messageLength = (int)length; // Process the message. try { replyWait = replyWait; haveReply = true; replyReadyRet = ProcessMessage((int)opcode, replyWait.reply) ? XBool.True:XBool.False; // We omit `swap' here, can one need it? Even theoretrically?.. } catch (NullReferenceException) { haveReply = false; replyReadyRet = ProcessMessage((int)opcode) ? XBool.True:XBool.False; } this.messageTransaction = false; }