Created
August 13, 2010 13:59
-
-
Save steefjan/522932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Event Handler for Read button click | |
/// </summary> | |
/// <param name="sender"></param> | |
/// <param name="e"></param> | |
private void btnRead_Click(object sender, EventArgs e) | |
{ | |
//create an instance MessageQueue, which points to the already existing Private Queue | |
MessageQueue mq = new MessageQueue(@".\PRIVATE$\SALESFORCECONTACT"); | |
//New instance of Message | |
System.Messaging.Message mes = new System.Messaging.Message(); | |
try | |
{ | |
//Receive message | |
mes = mq.Receive(new TimeSpan(0, 0, 3)); | |
//Instantie Binary Reader | |
BinaryReader reader = new BinaryReader(mes.BodyStream); | |
int count = (int)mes.BodyStream.Length; | |
byte[] bytes = reader.ReadBytes(count); | |
txtAccountDetails.Text = Encoding.UTF8.GetString(bytes); | |
} | |
catch | |
{ | |
//Case no message is read | |
txtAccountDetails.Text = "No Message"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment