Using system;
Using system. Collections. Generic;
Using system. text;
Using system. messaging;
Namespace queuetest
{
Class Program
{
Static void main (string [] ARGs)
{
String Path = @ ". \ private $ \ test ";
If (messagequeue. exists (PATH ))
{
Messagequeue. Delete (PATH );
}
// Create a message queue and send it
Messagequeue msq = messagequeue. Create (PATH );
Msq. Send (8 );
Msq. Send ("Jason ");
Mathes Mm = new mathes ();
Msq. Send (mm );
Msq. Send (mm );
// Team out
(Xmlmessageformatter) msq. formatter). targettypes = new type [] {typeof (system. int32 )};
Message M1 = msq. Receive ();
Console. writeline (m1.body. tostring ());
(Xmlmessageformatter) msq. formatter). targettypes = new type [] {typeof (system. String )};
Message m2 = msq. Receive ();
Console. writeline (m2.body. tostring ());
(Xmlmessageformatter) msq. formatter). targettypes = new type [] {typeof (mathes )};
Message m3 = msq. Receive ();
Console. writeline (Mm. sumab (10, 20 ));
# Region asynchronous
(Xmlmessageformatter) msq. formatter). targettypes = new type [] {typeof (mathes )};
Msq. beginreceive (New timespan (10000), msq, new asynccallback (mysum ));
# Endregion
Console. Read ();
}
Static void mysum (iasyncresult IA)
{
Messagequeue msq = IA. asyncstate as messagequeue;
Message M4 = msq. endreceive (IA );
Mathes Mm = m4.body as mathes;
Console. writeline (Mm. sumab (25, 35 ));
}
}
Public class mathes
{
Private int A = 25;
Private string B = "35 ";
Public String B
{
Get {return B ;}
Set {B = value ;}
}
Public int
{
Get {return ;}
Set {A = value ;}
}
Public int sumab (int A, int B)
{
Return A + B;
}
}
}