PeekCompletedEventArgs 클래스

정의

PeekCompleted 이벤트에 대한 데이터를 제공합니다.Provides data for the PeekCompleted event. 비동기 피킹(peeking) 작업에서 이벤트 처리기가 호출되면 이 클래스의 인스턴스가 해당 처리기로 전달됩니다.When your asynchronous peek operation calls an event handler, an instance of this class is passed to the handler.

public ref class PeekCompletedEventArgs : EventArgs
public class PeekCompletedEventArgs : EventArgs
type PeekCompletedEventArgs = class
    inherit EventArgs
Public Class PeekCompletedEventArgs
Inherits EventArgs
상속
PeekCompletedEventArgs

예제

다음 코드 예제에 대 한 이벤트 처리기를 만듭니다는 PeekCompleted 이벤트 및 이벤트를 사용 하 여 대리자를 사용 하 여 연결 된 PeekCompletedEventHandler합니다.The following code example creates an event handler for the PeekCompleted event and associates it with the event delegate by using the PeekCompletedEventHandler. 이벤트 처리기 MyPeekCompleted, 메시지 피킹 및 레이블을 해당 화면에 씁니다.The event handler, MyPeekCompleted, peeks a message and writes its label to the screen.

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;

// This example performs asynchronous peek operation
// processing.
//*************************************************
ref class MyNewQueue
{
public:

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

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

      // Display message information on the screen.
      Console::WriteLine( "Message: {0}", static_cast<String^>(m->Body) );

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

// Provides an entry point into the application.
//         
int main()
{
   // Create an instance of MessageQueue. Set its formatter.
   MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
   array<Type^>^p = gcnew array<Type^>(1);
   p[ 0 ] = String::typeid;
   myQueue->Formatter = gcnew XmlMessageFormatter( p );

   // Add an event handler for the PeekCompleted event.
   myQueue->PeekCompleted += gcnew PeekCompletedEventHandler( MyNewQueue::MyPeekCompleted );

   // Begin the asynchronous peek operation.
   myQueue->BeginPeek();

   // Do other work on the current thread.
   return 0;
}
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;
        }
    }
}
Imports System.Messaging





' Provides a container class for the example.
Public Class MyNewQueue



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


        Public Shared Sub Main()
            ' Create an instance of MessageQueue. Set its formatter.
            Dim myQueue As New MessageQueue(".\myQueue")
            myQueue.Formatter = New XmlMessageFormatter(New Type() _
                {GetType([String])})

            ' Add an event handler for the PeekCompleted event.
            AddHandler myQueue.PeekCompleted, AddressOf _
                MyPeekCompleted

            ' Begin the asynchronous peek operation.
            myQueue.BeginPeek()

            ' Do other work on the current thread.
            Return
        End Sub


        '**************************************************
        ' Provides an event handler for the PeekCompleted
        ' event.
        '**************************************************

        Private Shared Sub MyPeekCompleted(ByVal [source] As _
            [Object], ByVal asyncResult As PeekCompletedEventArgs)

            ' Connect to the queue.
            Dim mq As MessageQueue = CType([source], MessageQueue)

            ' End the asynchronous peek operation.
            Dim m As Message = mq.EndPeek(asyncResult.AsyncResult)

            ' Display message information on the screen.
            Console.WriteLine(("Message: " + CStr(m.Body)))

            ' Restart the asynchronous peek operation.
            mq.BeginPeek()

            Return

        End Sub

End Class

설명

를 사용 하면 이벤트 알림 메시지를 피킹할 (제거 하지 않고 읽음) 비동기적으로 큐에서 메시지를 처리 하는 메서드를 만들어야 합니다.When you use event notification to peek (read without removing) messages asynchronously from the queue, you must create a method that handles your message processing. 코드를 호출 해야 BeginPeek 여 비동기 처리를 시작 합니다.Your code must call BeginPeek to begin the asynchronous processing. 애플리케이션을 통해 알려집니다 메시지를 피킹하는 경우는 PeekCompleted 이벤트입니다.When a message is peeked, your application is notified through the PeekCompleted event. 인스턴스의 PeekCompletedEventArgs 이벤트 처리기를 호출 하는 이벤트 대리자에 전달 됩니다.An instance of PeekCompletedEventArgs is passed into the event delegate that calls your event handler. 연결 된 데이터를 PeekCompleted 이벤트는 대리자의에 포함 된 AsyncResult 매개 변수입니다.The data associated with the PeekCompleted event is contained in the delegate's AsyncResult parameter.

이벤트 완료에 대 한 알림을 제공 하는 방법은 두 가지: 이벤트 알림 및 콜백 합니다.There are two ways to provide notification of event completion: event notification and callbacks. PeekCompletedEventArgs 이벤트 알림 에서만 사용 됩니다.PeekCompletedEventArgs is used only with event notification. 콜백 및 이벤트 알림을 비교 내용은 "이벤트 및을 참조 하세요. 콜백 "MSDN에 있습니다.For information comparing callbacks and event notification, see "Events vs. Callbacks" on MSDN.

PeekCompletedEventArgs 통해 비동기 작업의 종료를 시작 하는 메시지에 대 한 액세스를 제공 합니다 Message 멤버입니다.PeekCompletedEventArgs provides access to the message that initiated the end of the asynchronous peek operation, through the Message member. 메시지에 대 한 대체 액세스 이며 동작에 대 한 호출 하는 것과 매우 MessageQueue.EndPeek합니다.This is an alternate access to the message, and behaves much the same as a call to MessageQueue.EndPeek.

속성

AsyncResult

요청한 비동기 작업의 결과를 가져오거나 설정합니다.Gets or sets the result of the asynchronous operation requested.

Message

비동기 피킹(peeking) 작업과 관련된 메시지를 가져옵니다.Gets the message associated with the asynchronous peek operation.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.Determines whether the specified object is equal to the current object.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(다음에서 상속됨 Object)

적용 대상

추가 정보