15,997,960 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Amit kumar pathak (Top 4 by date)
Amit kumar pathak
14-Apr-11 5:27am
View
Thanks to your solution your solution is correct in normal case actually in my program problem was inPtr and Marshal.Copy(buffer, 0, HeaderPtr, buffer.Length);. here it was taking so much of time, now i have use inPtr with GCHandle and its working very smooth.
Amit kumar pathak
15-Mar-11 1:49am
View
Yes you are correct i also found that problem while converting from binary to structure...
Amit kumar pathak
14-Mar-11 3:12am
View
i run your code using source provided by you(http://www.codeproject.com/KB/cs/Harlinn_Messaging.aspx) worked well, but when i implement it in my program then it gets hanged within a minute and stopped working.... Kindly help me out your help to make running program will be so helpfull...if you provide your email then i'll send fulll code ...
namespace udpConsume
{
public partial class FormReceive : Form
{
private MessageQueue messageQueue;
private bool isRunning;
public FormReceive()
{
InitializeComponent();
InitializeQueue();
}
private void InitializeQueue()
{
receivedCounter = 0;
string queuePath = @".\private$\myquelocal";
if (!MessageQueue.Exists(queuePath))
{
messageQueue = MessageQueue.Create(queuePath);
}
else
{
messageQueue = new MessageQueue(queuePath);
}
isRunning = true;
messageQueue.Formatter = new BinaryMessageFormatter();
messageQueue.ReceiveCompleted += OnReceiveCompleted;
messageQueue.BeginReceive();
}
private delegate void LogMessageDelegate(string text);
private void LogMessage(string text)
{
if (InvokeRequired)
{
Invoke(new LogMessageDelegate(LogMessage), text);
}
else
{
messageTextBox.AppendText(text + Environment.NewLine);
}
}
private int receivedCounter;
private void OnReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult)
{
try
{
MessageQueue mq = (MessageQueue)source;
if (mq != null)
{
try
{
System.Messaging.Message message = null;
try
{
message = mq.EndReceive(asyncResult.AsyncResult);
}
catch (Exception ex)
{
LogMessage(ex.Message);
}
if (message != null)
{
byte[] buffer = (byte[])message.Body;
if (buffer.Length > 0)
{
receivedCounter++;
if ((receivedCounter % 10) == 0)
{
TBCastMessageHeader bcastHeader = new TBCastMessageHeader();
IntPtr bcastHeaderPtr;
bcastHeaderPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TBCastMessageHeader)));
Marshal.Copy(buffer, 0, bcastHeaderPtr, buffer.Length);
bcastHeader = (TBCastMessageHeader)(Marshal.PtrToStructure(bcastHeaderPtr, typeof(TBCastMessageHeader)));
//MessageBox.Show(bcastHeader.MessageCode.ToString());
try
{
LogMessage(bcastHeader.MessageCode.ToString());
string ChngSign = "";
switch (bcastHeader.MessageCode)
{
case 1001: //usp_Insert1001data
TMarketUpdateMsg marketupdMsg;
IntPtr marketPtr;
marketPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TMarketUpdateMsg)));
Marshal.C
Amit kumar pathak
12-Mar-11 8:22am
View
when i tried with this cpu goes to 40% and suddenly stooped exe.. kindly help me out..