Click here to Skip to main content
15,911,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: I am working on software in that i need to print certain things....... which is the easy way........ kindly help Pin
0x3c016-Sep-09 8:50
0x3c016-Sep-09 8:50 
AnswerRe: I am working on software in that i need to print certain things....... which is the easy way........ kindly help Pin
carlecomm21-Sep-09 19:15
carlecomm21-Sep-09 19:15 
Questionusing console application as service Pin
Rabia_Arif16-Sep-09 6:55
Rabia_Arif16-Sep-09 6:55 
AnswerRe: using console application as service Pin
Alan N16-Sep-09 7:05
Alan N16-Sep-09 7:05 
AnswerRe: using console application as service Pin
Muhammad Mazhar16-Sep-09 11:24
Muhammad Mazhar16-Sep-09 11:24 
QuestionRunnable and Next Run Date is not coming with job created in Job Activity monitor c# Pin
deepak_dubey16-Sep-09 6:33
deepak_dubey16-Sep-09 6:33 
AnswerRe: Runnable and Next Run Date is not coming with job created in Job Activity monitor c# Pin
deepak_dubey17-Sep-09 20:17
deepak_dubey17-Sep-09 20:17 
QuestionWindows Message Queue Asynchronous Peek Problem Pin
faheemnadeem16-Sep-09 5:24
faheemnadeem16-Sep-09 5:24 
Hi,
I am currently Implementing a Tcp Server and a serial server which are running as services and receives events from a GUI based service controller through a message queue.
I wish to peek messages on the queue as the queue is shared by both the servers and i want the data to be received somewhere else.
I used the code provided at msdn for the asynchronous peek.
using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        /***************************************************/
        // Provides an entry point into the application.
        //         
        // This example performs asynchronous peek operation
        // processing.
        /***************************************************/

        public static void Main()
        {
            // Create an instance of MessageQueue. Set its formatter.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(String)});

            // Add an event handler for the PeekCompleted event.
            myQueue.PeekCompleted += new 
                PeekCompletedEventHandler(MyPeekCompleted);
            
            // Begin the asynchronous peek operation.
            myQueue.BeginPeek();
            
            // Do other work on the current thread.

            return;
        }


        /***************************************************/
        // Provides an event handler for the PeekCompleted
        // event.
        /***************************************************/
        
        private static void MyPeekCompleted(Object source, 
            PeekCompletedEventArgs asyncResult)
        {
            // Connect to the queue.
            MessageQueue mq = (MessageQueue)source;

            // End the asynchronous peek operation.
            Message m = mq.EndPeek(asyncResult.AsyncResult);

            // Display message information on the screen.
            Console.WriteLine("Message: " + (string)m.Body);

            // Restart the asynchronous peek operation.
            mq.BeginPeek();
            
            return; 
        }
    }
}

The problem is once a message is sent to the queue the peek event on service end fires perfectly, but keeps on firing for the same message. what i want is that the peek method should only fire once for any message received and then fires on consecutive message received, just like as a receive event works.
The problem lies somewhere in restarting the asynchronous peek and the logic involved in getting the messages.
Help Please!!!
AnswerRe: Windows Message Queue Asynchronous Peek Problem Pin
Matt Meyer16-Sep-09 6:14
Matt Meyer16-Sep-09 6:14 
GeneralRe: Windows Message Queue Asynchronous Peek Problem Pin
faheemnadeem16-Sep-09 17:50
faheemnadeem16-Sep-09 17:50 
GeneralRe: Windows Message Queue Asynchronous Peek Problem Pin
Matt Meyer17-Sep-09 7:01
Matt Meyer17-Sep-09 7:01 
QuestionFile Format Pin
Senseicads16-Sep-09 4:45
Senseicads16-Sep-09 4:45 
AnswerRe: File Format Pin
Eddy Vluggen16-Sep-09 4:49
professionalEddy Vluggen16-Sep-09 4:49 
GeneralRe: File Format Pin
Senseicads16-Sep-09 4:55
Senseicads16-Sep-09 4:55 
GeneralRe: File Format Pin
Eddy Vluggen16-Sep-09 5:20
professionalEddy Vluggen16-Sep-09 5:20 
GeneralRe: File Format Pin
Senseicads16-Sep-09 5:23
Senseicads16-Sep-09 5:23 
GeneralRe: File Format Pin
Eddy Vluggen16-Sep-09 5:28
professionalEddy Vluggen16-Sep-09 5:28 
GeneralRe: File Format Pin
Not Active16-Sep-09 5:31
mentorNot Active16-Sep-09 5:31 
GeneralRe: File Format Pin
Eddy Vluggen16-Sep-09 5:33
professionalEddy Vluggen16-Sep-09 5:33 
GeneralRe: File Format Pin
Not Active16-Sep-09 5:29
mentorNot Active16-Sep-09 5:29 
RantRe: File Format Pin
Eddy Vluggen16-Sep-09 5:39
professionalEddy Vluggen16-Sep-09 5:39 
AnswerRe: File Format Pin
Luc Pattyn16-Sep-09 5:03
sitebuilderLuc Pattyn16-Sep-09 5:03 
GeneralRe: File Format Pin
Senseicads16-Sep-09 5:08
Senseicads16-Sep-09 5:08 
GeneralRe: File Format Pin
Luc Pattyn16-Sep-09 5:22
sitebuilderLuc Pattyn16-Sep-09 5:22 
GeneralRe: File Format Pin
Senseicads16-Sep-09 5:28
Senseicads16-Sep-09 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.