MessageQueue.BeginReceive 메서드

정의

메시지 큐가 메시지 수신을 시작하도록 한 후, 작업을 마치면 이벤트 처리기에 알리도록 하여 비동기 수신 작업을 시작합니다.

오버로드

BeginReceive()

시간 제한이 없는 비동기 수신 작업을 시작합니다. 큐에서 메시지를 사용할 수 있을 때까지 작업이 완료되지 않습니다.

BeginReceive(TimeSpan)

지정된 시간 제한이 있는 비동기 수신 작업을 시작합니다. 큐에서 메시지를 사용할 수 있거나 시간이 초과될 때까지 작업이 완료되지 않습니다.

BeginReceive(TimeSpan, Object)

시간 제한 및 상태 개체가 지정되어 있는 비동기 수신 작업을 시작합니다. 이는 작업의 수명이 지속되는 동안 관련된 정보를 제공합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

BeginReceive(TimeSpan, Object, AsyncCallback)

시간 제한 및 상태 개체가 지정되어 있는 비동기 수신 작업을 시작합니다. 이는 작업의 수명이 지속되는 동안 관련된 정보를 제공합니다. 이 오버로드는 콜백을 통해 해당 작업의 이벤트 처리기 ID에 대한 알림을 수신합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

BeginReceive(TimeSpan, Cursor, Object, AsyncCallback)

지정된 제한 시간이 있고 지정된 커서 및 지정된 상태 개체를 사용하는 비동기 수신 작업을 초기화합니다. 상태 개체는 전체 작업 기간 동안 관련 정보를 제공합니다. 이 오버로드는 콜백을 통해 해당 작업의 이벤트 처리기 ID에 대한 알림을 수신합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

BeginReceive()

시간 제한이 없는 비동기 수신 작업을 시작합니다. 큐에서 메시지를 사용할 수 있을 때까지 작업이 완료되지 않습니다.

public:
 IAsyncResult ^ BeginReceive();
public IAsyncResult BeginReceive ();
member this.BeginReceive : unit -> IAsyncResult
Public Function BeginReceive () As IAsyncResult

반환

게시된 비동기 요청을 식별하는 IAsyncResult 입니다.

예외

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 비동기 요청을 연결합니다. 로컬 컴퓨터에 "myQueue"라는 큐가 있다고 가정합니다. 함수는 Main 루틴에서 처리하는 MyReceiveCompleted 비동기 작업을 시작합니다. MyReceiveCompleted 는 현재 메시지를 처리하고 새 비동기 수신 작업을 시작합니다.

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

using namespace System;
using namespace System::Messaging;
using namespace System::Threading;

ref class MyNewQueue
{
public:

   // Define static class members.
   static ManualResetEvent^ signal = gcnew ManualResetEvent( false );
   static int count = 0;

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

         // End the asynchronous receive operation.
         mq->EndReceive( asyncResult->AsyncResult );
         count += 1;
         if ( count == 10 )
         {
            signal->Set();
         }

         // Restart the asynchronous receive operation.
         mq->BeginReceive();
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle sources of MessageQueueException.
      }

      // Handle other exceptions.
      return;
   }
};

// Provides an entry point into the application.
//         
// This example performs asynchronous receive
// operation processing.
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 ReceiveCompleted event.
   myQueue->ReceiveCompleted += gcnew ReceiveCompletedEventHandler( MyNewQueue::MyReceiveCompleted );

   // Begin the asynchronous receive operation.
   myQueue->BeginReceive();
   MyNewQueue::signal->WaitOne();

   // Do other work on the current thread.
   return 0;
}
using System;
using System.Messaging;
using System.Threading;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {
        // Define static class members.
        static ManualResetEvent signal = new ManualResetEvent(false);
        static int count = 0;

        //**************************************************
        // Provides an entry point into the application.
        //		
        // This example performs asynchronous receive
        // 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 ReceiveCompleted event.
            myQueue.ReceiveCompleted +=
                new ReceiveCompletedEventHandler(MyReceiveCompleted);
            
            // Begin the asynchronous receive operation.
            myQueue.BeginReceive();

            signal.WaitOne();
            
            // Do other work on the current thread.

            return;
        }

        //***************************************************
        // Provides an event handler for the ReceiveCompleted
        // event.
        //***************************************************
        
        private static void MyReceiveCompleted(Object source,
            ReceiveCompletedEventArgs asyncResult)
        {
            try
            {
                // Connect to the queue.
                MessageQueue mq = (MessageQueue)source;

                // End the asynchronous receive operation.
                Message m = mq.EndReceive(asyncResult.AsyncResult);
                
                count += 1;
                if (count == 10)
                {
                    signal.Set();
                }

                // Restart the asynchronous receive operation.
                mq.BeginReceive();
            }
            catch(MessageQueueException)
            {
                // Handle sources of MessageQueueException.
            }
            
            // Handle other exceptions.
            
            return;
        }
    }
}
Imports System.Messaging
Imports System.Threading




' Provides a container class for the example.

Public Class MyNewQueue

        ' Define static class members.
        Private Shared signal As New ManualResetEvent(False)
        Private Shared count As Integer = 0



        ' Provides an entry point into the application.
        '		 
        ' This example performs asynchronous receive
        ' 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 ReceiveCompleted event.
            AddHandler myQueue.ReceiveCompleted, AddressOf _
                MyReceiveCompleted

            ' Begin the asynchronous receive operation.
            myQueue.BeginReceive()

            signal.WaitOne()

            ' Do other work on the current thread.

            Return

        End Sub



        ' Provides an event handler for the ReceiveCompleted
        ' event.


        Private Shared Sub MyReceiveCompleted(ByVal [source] As _
            [Object], ByVal asyncResult As ReceiveCompletedEventArgs)

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

                ' End the asynchronous receive operation.
                Dim m As Message = _
                    mq.EndReceive(asyncResult.AsyncResult)

                count += 1
                If count = 10 Then
                    signal.Set()
                End If

                ' Restart the asynchronous receive operation.
                mq.BeginReceive()

            Catch
                ' Handle sources of MessageQueueException.

                ' Handle other exceptions.

            End Try

            Return

        End Sub

End Class

다음 코드 예제에서는 비동기 요청을 큐에 추가합니다. 에 대한 BeginReceive 호출은 반환 값에서 를 사용합니다 AsyncWaitHandle . 루틴은 Main 종료하기 전에 모든 비동기 작업이 완료될 때까지 기다립니다.

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

using namespace System;
using namespace System::Messaging;
using namespace System::Threading;

ref class MyNewQueue
{
public:

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

         // End the asynchronous receive operation.
         mq->EndReceive( asyncResult->AsyncResult );

         // Process the message here.
         Console::WriteLine( "Message received." );
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle sources of MessageQueueException.
      }
      // Handle other exceptions.
      return;
   }
};

// Provides an entry point into the application.
//         
// This example performs asynchronous receive
// operation processing.
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 ReceiveCompleted event.
   myQueue->ReceiveCompleted += gcnew ReceiveCompletedEventHandler( MyNewQueue::MyReceiveCompleted );

   // Define wait handles for multiple operations.
   array<WaitHandle^>^waitHandleArray = gcnew array<WaitHandle^>(10);
   for ( int i = 0; i < 10; i++ )
   {
      // Begin asynchronous operations.
      waitHandleArray[ i ] = myQueue->BeginReceive()->AsyncWaitHandle;
   }

   // Specify to wait for all operations to return.
   WaitHandle::WaitAll( waitHandleArray );
   return 0;
}
using System;
using System.Messaging;
using System.Threading;

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 receive
        // 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 ReceiveCompleted event.
            myQueue.ReceiveCompleted +=
                new ReceiveCompletedEventHandler(MyReceiveCompleted);
            
            // Define wait handles for multiple operations.
            WaitHandle[] waitHandleArray = new WaitHandle[10];
            for(int i=0; i<10; i++)
            {
                // Begin asynchronous operations.
                waitHandleArray[i] =
                    myQueue.BeginReceive().AsyncWaitHandle;
            }

            // Specify to wait for all operations to return.
            WaitHandle.WaitAll(waitHandleArray);

            return;
        }

        //***************************************************
        // Provides an event handler for the ReceiveCompleted
        // event.
        //***************************************************
        
        private static void MyReceiveCompleted(Object source,
            ReceiveCompletedEventArgs asyncResult)
        {
            try
            {
                // Connect to the queue.
                MessageQueue mq = (MessageQueue)source;

                // End the asynchronous receive operation.
                Message m = mq.EndReceive(asyncResult.AsyncResult);
        
                // Process the message here.
                Console.WriteLine("Message received.");
            }
            catch(MessageQueueException)
            {
                // Handle sources of MessageQueueException.
            }
            
            // Handle other exceptions.
            
            return;
        }
    }
}
Imports System.Messaging
Imports System.Threading


' Provides a container class for the example.

Public Class MyNewQueue


        ' Provides an entry point into the application.
        '		 
        ' This example performs asynchronous receive
        ' 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 ReceiveCompleted event.
            AddHandler myQueue.ReceiveCompleted, AddressOf _
                MyReceiveCompleted

            ' Define wait handles for multiple operations.
            Dim waitHandleArray(10) As WaitHandle

            Dim i As Integer
            For i = 0 To 9
                ' Begin asynchronous operations.
                waitHandleArray(i) = _
                    myQueue.BeginReceive().AsyncWaitHandle
            Next i

            ' Specify to wait for all operations to return.
            WaitHandle.WaitAll(waitHandleArray)

            Return

        End Sub



        ' Provides an event handler for the ReceiveCompleted
        ' event.


        Private Shared Sub MyReceiveCompleted(ByVal [source] As _
            [Object], ByVal asyncResult As ReceiveCompletedEventArgs)

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

                ' End the asynchronous receive operation.
                Dim m As Message = _
                    mq.EndReceive(asyncResult.AsyncResult)

                ' Process the message here.
                Console.WriteLine("Message received.")

            Catch

                ' Handle sources of MessageQueueException.

                ' Handle other exceptions.

            End Try

            Return

        End Sub

End Class

설명

비동기 처리에서는 를 사용하여 BeginReceive 큐에서 메시지가 제거되었을 때 이벤트를 발생 ReceiveCompleted 합니다.

ReceiveCompleted 는 큐에 메시지가 이미 있는 경우에도 발생합니다.

를 사용 BeginReceive하려면 비동기 작업의 결과를 처리하고 이벤트 대리자와 연결하는 이벤트 처리기를 만듭니다. BeginReceive 는 비동기 수신 작업을 시작합니다. 는 MessageQueue 메시지가 큐에 도착할 때 이벤트 발생 ReceiveCompleted 을 통해 알림을 받습니다. 그런 다음 를 MessageQueue 호출 EndReceive(IAsyncResult)하여 메시지에 액세스할 수 있습니다.

메서드는 BeginReceive 즉시 반환되지만 이벤트 처리기가 호출될 때까지 비동기 작업이 완료되지 않습니다.

BeginReceive 는 비동기이므로 현재 실행 스레드를 차단하지 않고 큐에서 메시지를 수신하도록 호출할 수 있습니다. 메시지를 동기적으로 받으려면 메서드를 Receive 사용합니다.

비동기 작업이 완료되면 이벤트 처리기에서 또는 BeginReceive 다시 호출 BeginPeek 하여 알림을 계속 받을 수 있습니다.

를 반환하는 BeginReceiveIAsyncResult 메서드가 시작한 비동기 작업을 식별합니다. 일반적으로 가 호출될 때까지 EndReceive(IAsyncResult) 는 사용하지 않지만 작업의 수명 동안 사용할 IAsyncResult 수 있습니다. 그러나 여러 비동기 작업을 시작하는 경우 해당 값을 배열에 배치 IAsyncResult 하고 모든 작업 또는 작업이 완료되기를 기다릴지 여부를 지정할 수 있습니다. 이 경우 의 속성을 IAsyncResult 사용하여 AsyncWaitHandle 완료된 작업을 식별합니다.

가 이falseCanRead 완료 이벤트가 발생하지만 를 호출EndReceive(IAsyncResult)할 때 예외가 throw됩니다.

트랜잭션과 함께 비동기 호출 BeginReceive 을 사용하지 마세요. 트랜잭션 비동기 작업을 수행하려면 를 호출 BeginPeek하고 피킹 작업을 위해 만든 이벤트 처리기 내에 트랜잭션 및 (동기) Receive 메서드를 배치합니다. 다음 C# 코드와 같이 이벤트 처리기에 기능이 포함될 수 있습니다.

myMessageQueue.BeginTransaction();
 myMessageQueue.Receive();
 myMessageQueue.CommitTransaction();

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

BeginReceive(TimeSpan)

지정된 시간 제한이 있는 비동기 수신 작업을 시작합니다. 큐에서 메시지를 사용할 수 있거나 시간이 초과될 때까지 작업이 완료되지 않습니다.

public:
 IAsyncResult ^ BeginReceive(TimeSpan timeout);
public IAsyncResult BeginReceive (TimeSpan timeout);
member this.BeginReceive : TimeSpan -> IAsyncResult
Public Function BeginReceive (timeout As TimeSpan) As IAsyncResult

매개 변수

timeout
TimeSpan

메시지를 사용할 수 있을 때까지 기다리는 시간 간격을 나타내는 TimeSpan입니다.

반환

게시된 비동기 요청을 식별하는 IAsyncResult 입니다.

예외

timeout 매개 변수에 지정된 값이 잘못된 경우 (예: 값이 음수인 경우)

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 비동기 수신 작업을 만듭니다. 코드 예제에서는 이벤트 처리기를 만들고 이벤트 처리 MyReceiveCompleted기 대리자 에 ReceiveCompleted 연결합니다. 코드 예제는 로컬 메시지 큐에 메시지를 보낸 다음, 를 호출 BeginReceive(TimeSpan)하여 10초의 제한 시간 값을 전달합니다. ReceiveCompleted 이벤트가 발생하면 이벤트 처리기가 메시지를 수신하고 메시지 본문을 화면에 씁니다.

#using <System.Messaging.dll>
#using <System.dll>

using namespace System;
using namespace System::Messaging;

// Creates a new queue.
void CreateQueue(String^ queuePath, bool transactional)
{
    if(!MessageQueue::Exists(queuePath))
    {
        MessageQueue^ queue = MessageQueue::Create(queuePath, transactional);
        queue->Close();       
    }
    else
    {
        Console::WriteLine("{0} already exists.", queuePath);
    }
}

// Provides an event handler for the ReceiveCompleted event.
void HandleReceiveCompleted(Object^ source, ReceiveCompletedEventArgs^ e)
{
    // Connect to the queue.
    MessageQueue^ queue = (MessageQueue^)source;

    // End the asynchronous receive operation.
    Message^ msg = queue->EndReceive(e->AsyncResult);

    // Display the message information on the screen.
    Console::WriteLine("Message body: {0}", msg->Body);
    
    queue->Close();
}

int main()
{
    // Create a non-transactional queue on the local computer.
    // Note that the queue might not be immediately accessible, and
    // therefore this example might throw an exception of type
    // System.Messaging.MessageQueueException when trying to send a
    // message to the newly created queue.
    MessageQueue^ queue = nullptr;
    try
    {
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        queue = gcnew MessageQueue(".\\exampleQueue");

        // Add an event handler for the ReceiveCompleted event.
        queue->ReceiveCompleted += gcnew
            ReceiveCompletedEventHandler(HandleReceiveCompleted);

        // Send a message to the queue.
        queue->Send("Example Message");

        // Begin the asynchronous receive operation.
        queue->BeginReceive(TimeSpan::FromSeconds(10.0));

        // Simulate doing other work on the current thread.
        System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0));
    }

    catch (InvalidOperationException^)
    {
        Console::WriteLine("Please install Message Queuing.");
    }

    catch (MessageQueueException^ ex)
    {
        Console::WriteLine(ex->Message);
    }

    finally
    {   
        queue->Close();
    }

}

using System;
using System.Messaging;

public class QueueExample
{
    public static void Main()
    {
        // Create a non-transactional queue on the local computer.
        // Note that the queue might not be immediately accessible, and
        // therefore this example might throw an exception of type
        // System.Messaging.MessageQueueException when trying to send a
        // message to the newly created queue.
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Add an event handler for the ReceiveCompleted event.
        queue.ReceiveCompleted += new
                ReceiveCompletedEventHandler(MyReceiveCompleted);

        // Send a message to the queue.
        queue.Send("Example Message");

        // Begin the asynchronous receive operation.
        queue.BeginReceive(TimeSpan.FromSeconds(10.0));

        // Simulate doing other work on the current thread.
        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10.0));

        return;
    }

    // Creates a new queue.
    public static void CreateQueue(string queuePath, bool transactional)
    {
        if(!MessageQueue.Exists(queuePath))
        {
            MessageQueue.Create(queuePath, transactional);
        }
        else
        {
            Console.WriteLine(queuePath + " already exists.");
        }
    }

    // Provides an event handler for the ReceiveCompleted event.
    private static void MyReceiveCompleted(Object source,
        ReceiveCompletedEventArgs asyncResult)
    {
        // Connect to the queue.
        MessageQueue queue = (MessageQueue)source;

        // End the asynchronous receive operation.
        Message msg = queue.EndReceive(asyncResult.AsyncResult);

        // Display the message information on the screen.
        Console.WriteLine("Message body: {0}", (string)msg.Body);
    }
}

설명

비동기 처리에서는 를 사용하여 BeginReceive 큐에서 메시지를 사용할 수 있게 되거나 지정된 시간 간격이 만료된 경우 이벤트를 발생 ReceiveCompleted 합니다.

ReceiveCompleted 는 큐에 메시지가 이미 있는 경우에도 발생합니다.

를 사용 BeginReceive하려면 비동기 작업의 결과를 처리하고 이벤트 대리자와 연결하는 이벤트 처리기를 만듭니다. BeginReceive 는 비동기 수신 작업을 시작합니다. 는 MessageQueue 메시지가 큐에 도착할 때 이벤트 발생 ReceiveCompleted 을 통해 알림을 받습니다. 그런 다음 은 MessageQueue 를 사용하여 결과를 호출 EndReceive(IAsyncResult) 하거나 검색하여 메시지에 액세스할 수 있습니다 ReceiveCompletedEventArgs.

메서드는 BeginReceive 즉시 반환되지만 이벤트 처리기가 호출될 때까지 비동기 작업이 완료되지 않습니다.

BeginReceive 는 비동기이므로 현재 실행 스레드를 차단하지 않고 큐에서 메시지를 수신하도록 호출할 수 있습니다. 메시지를 동기적으로 받으려면 메서드를 Receive 사용합니다.

비동기 작업이 완료되면 이벤트 처리기에서 또는 BeginReceive 다시 호출 BeginPeek 하여 알림을 계속 받을 수 있습니다.

가 이falseCanRead 완료 이벤트가 발생하지만 를 호출EndReceive(IAsyncResult)할 때 예외가 throw됩니다.

를 반환하는 BeginReceiveIAsyncResult 메서드가 시작한 비동기 작업을 식별합니다. 일반적으로 가 호출될 때까지 EndReceive(IAsyncResult) 는 사용하지 않지만 작업의 수명 동안 사용할 IAsyncResult 수 있습니다. 그러나 여러 비동기 작업을 시작하는 경우 해당 값을 배열에 배치 IAsyncResult 하고 모든 작업 또는 작업이 완료되기를 기다릴지 여부를 지정할 수 있습니다. 이 경우 의 속성을 IAsyncResult 사용하여 AsyncWaitHandle 완료된 작업을 식별합니다.

이 오버로드는 시간 초과를 지정합니다. 매개 변수로 지정된 간격이 timeout 만료되면 이 구성 요소는 이벤트를 발생합니다 ReceiveCompleted . 메시지가 없으므로 에 대한 후속 호출 EndReceive(IAsyncResult) 은 예외를 throw합니다.

트랜잭션과 함께 비동기 호출 BeginReceive 을 사용하지 마세요. 트랜잭션 비동기 작업을 수행하려면 를 호출 BeginPeek하고 피킹 작업을 위해 만든 이벤트 처리기 내에 트랜잭션 및 (동기) Receive 메서드를 배치합니다. 다음 C# 코드와 같이 이벤트 처리기에 기능이 포함될 수 있습니다.

myMessageQueue.BeginTransaction();
 myMessageQueue.Receive();
 myMessageQueue.CommitTransaction();

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

BeginReceive(TimeSpan, Object)

시간 제한 및 상태 개체가 지정되어 있는 비동기 수신 작업을 시작합니다. 이는 작업의 수명이 지속되는 동안 관련된 정보를 제공합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

public:
 IAsyncResult ^ BeginReceive(TimeSpan timeout, System::Object ^ stateObject);
public IAsyncResult BeginReceive (TimeSpan timeout, object stateObject);
member this.BeginReceive : TimeSpan * obj -> IAsyncResult
Public Function BeginReceive (timeout As TimeSpan, stateObject As Object) As IAsyncResult

매개 변수

timeout
TimeSpan

메시지를 사용할 수 있을 때까지 기다리는 시간 간격을 나타내는 TimeSpan입니다.

stateObject
Object

비동기 작업과 관련된 정보가 들어 있는 상태 개체이며 애플리케이션에서 지정합니다.

반환

게시된 비동기 요청을 식별하는 IAsyncResult 입니다.

예외

timeout 매개 변수에 지정된 값이 잘못된 경우

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 비동기 수신 작업을 만듭니다. 코드 예제에서는 이벤트 처리기를 만들고 이벤트 처리 MyReceiveCompleted기 대리자 에 ReceiveCompleted 연결합니다. 이 코드 예제에서는 로컬 메시지 큐에 메시지를 보낸 다음 를 호출 BeginReceive(TimeSpan, Object)하여 10초의 제한 시간 값과 해당 특정 메시지를 식별하는 고유 정수로 전달합니다. ReceiveCompleted 이벤트가 발생하면 이벤트 처리기가 메시지를 수신하고 메시지 본문과 정수 메시지 식별자를 화면에 씁니다.

#using <System.Messaging.dll>
#using <System.dll>

using namespace System;
using namespace System::Messaging;

// Creates a new queue.
void CreateQueue(String^ queuePath, bool transactional)
{
    if(!MessageQueue::Exists(queuePath))
    {
        MessageQueue^ queue = MessageQueue::Create(queuePath, transactional);
        queue->Close();       
    }
    else
    {
        Console::WriteLine("{0} already exists.", queuePath);
    }
}

// Provides an event handler for the ReceiveCompleted event.
void HandleReceiveCompleted(Object^ source, ReceiveCompletedEventArgs^ e)
{
    // Connect to the queue.
    MessageQueue^ queue = (MessageQueue^)source;

    // End the asynchronous receive operation.
    Message^ msg = queue->EndReceive(e->AsyncResult);

    // Display the message information on the screen.
    Console::WriteLine("Message number: {0}", e->AsyncResult->AsyncState);
    Console::WriteLine("Message body: {0}", msg->Body);

    queue->Close();
}

int main()
{
    // Create a non-transactional queue on the local computer.
    // Note that the queue might not be immediately accessible, and
    // therefore this example might throw an exception of type
    // System.Messaging.MessageQueueException when trying to send a
    // message to the newly created queue.
    MessageQueue^ queue = nullptr;

    // Represents a state object associated with each message.
    int messageNumber = 0;

    try
    {
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        queue = gcnew MessageQueue(".\\exampleQueue");

        // Add an event handler for the ReceiveCompleted event.
        queue->ReceiveCompleted += gcnew
            ReceiveCompletedEventHandler(HandleReceiveCompleted);

        // Send a message to the queue.
        queue->Send("Example Message");

        // Begin the asynchronous receive operation.
        queue->BeginReceive(TimeSpan::FromSeconds(10.0), messageNumber++);

        // Simulate doing other work on the current thread.
        System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0));
    }
    catch (InvalidOperationException^)
    {
        Console::WriteLine("Please install Message Queuing.");
    }

    catch (MessageQueueException^ ex)
    {
        Console::WriteLine(ex->Message);
    }

    finally
    {   
        queue->Close();
    }
}

using System;
using System.Messaging;

public class QueueExample
{
    // Represents a state object associated with each message.
    static int messageNumber = 0;

    public static void Main()
    {
        // Create a non-transactional queue on the local computer.
        // Note that the queue might not be immediately accessible, and
        // therefore this example might throw an exception of type
        // System.Messaging.MessageQueueException when trying to send a
        // message to the newly created queue.
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Add an event handler for the ReceiveCompleted event.
        queue.ReceiveCompleted += new
            ReceiveCompletedEventHandler(MyReceiveCompleted);

        // Send a message to the queue.
        queue.Send("Example Message");

        // Begin the asynchronous receive operation.
        queue.BeginReceive(TimeSpan.FromSeconds(10.0), messageNumber++);

        // Simulate doing other work on the current thread.
        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10.0));

        return;
    }

    // Creates a new queue.
    public static void CreateQueue(string queuePath, bool transactional)
    {
        if(!MessageQueue.Exists(queuePath))
        {
            MessageQueue.Create(queuePath, transactional);
        }
        else
        {
            Console.WriteLine(queuePath + " already exists.");
        }
    }

    // Provides an event handler for the ReceiveCompleted event.
    private static void MyReceiveCompleted(Object source,
        ReceiveCompletedEventArgs asyncResult)
    {
        // Connect to the queue.
        MessageQueue queue = (MessageQueue)source;

        // End the asynchronous receive operation.
        Message msg = queue.EndReceive(asyncResult.AsyncResult);

        // Display the message information on the screen.
        Console.WriteLine("Message number: {0}",
            (int)asyncResult.AsyncResult.AsyncState);
        Console.WriteLine("Message body: {0}", (string)msg.Body);
    }
}

설명

비동기 처리에서는 를 사용하여 BeginReceive 큐에서 메시지를 사용할 수 있게 되거나 지정된 시간 간격이 만료된 경우 이벤트를 발생 ReceiveCompleted 합니다.

ReceiveCompleted 는 큐에 메시지가 이미 있는 경우에도 발생합니다.

이 오버로드를 사용하여 작업의 수명 동안 유지되는 작업과 정보를 연결합니다. 이벤트 처리기는 작업과 연결된 의 IAsyncResult 속성을 확인 AsyncState 하여 이 정보를 검색할 수 있습니다.

를 사용 BeginReceive하려면 비동기 작업의 결과를 처리하고 이벤트 대리자와 연결하는 이벤트 처리기를 만듭니다. BeginReceive 는 비동기 수신 작업을 시작합니다. 는 MessageQueue 메시지가 큐에 도착할 때 이벤트 발생 ReceiveCompleted 을 통해 알림을 받습니다. 그런 다음 은 MessageQueue 를 사용하여 결과를 호출 EndReceive(IAsyncResult) 하거나 검색하여 메시지에 액세스할 수 있습니다 ReceiveCompletedEventArgs.

메서드는 BeginReceive 즉시 반환되지만 이벤트 처리기가 호출될 때까지 비동기 작업이 완료되지 않습니다.

BeginReceive 는 비동기이므로 현재 실행 스레드를 차단하지 않고 큐에서 메시지를 수신하도록 호출할 수 있습니다. 메시지를 동기적으로 받으려면 메서드를 Receive 사용합니다.

비동기 작업이 완료되면 이벤트 처리기에서 또는 BeginReceive 다시 호출 BeginPeek 하여 알림을 계속 받을 수 있습니다.

를 반환하는 BeginReceiveIAsyncResult 메서드가 시작한 비동기 작업을 식별합니다. 일반적으로 가 호출될 때까지 EndReceive(IAsyncResult) 는 사용하지 않지만 작업의 수명 동안 사용할 IAsyncResult 수 있습니다. 그러나 여러 비동기 작업을 시작하는 경우 해당 값을 배열에 배치 IAsyncResult 하고 모든 작업 또는 작업이 완료되기를 기다릴지 여부를 지정할 수 있습니다. 이 경우 의 속성을 IAsyncResult 사용하여 AsyncWaitHandle 완료된 작업을 식별합니다.

이 오버로드는 시간 제한 및 상태 개체를 지정합니다. 매개 변수로 지정된 간격이 timeout 만료되면 이 구성 요소는 이벤트를 발생합니다 ReceiveCompleted . 메시지가 없으므로 에 대한 후속 호출 EndReceive(IAsyncResult) 은 예외를 throw합니다.

상태 개체는 작업과 상태 정보를 연결합니다. 예를 들어 여러 작업을 시작하기 위해 여러 번 호출 BeginReceive 하는 경우 정의하는 별도의 상태 개체를 통해 각 작업을 식별할 수 있습니다.

상태 개체를 사용하여 프로세스 스레드 간에 정보를 전달할 수도 있습니다. 스레드가 시작되었지만 콜백이 비동기 시나리오에서 다른 스레드에 있는 경우 상태 개체가 마샬링되고 이벤트의 정보와 함께 다시 전달됩니다.

트랜잭션과 함께 비동기 호출 BeginReceive 을 사용하지 마세요. 트랜잭션 비동기 작업을 수행하려면 를 호출 BeginPeek하고 피킹 작업을 위해 만든 이벤트 처리기 내에 트랜잭션 및 (동기) Receive 메서드를 배치합니다. 다음 C# 코드와 같이 이벤트 처리기에 기능이 포함될 수 있습니다.

myMessageQueue.BeginTransaction();
 myMessageQueue.Receive();
 myMessageQueue.CommitTransaction();

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

BeginReceive(TimeSpan, Object, AsyncCallback)

시간 제한 및 상태 개체가 지정되어 있는 비동기 수신 작업을 시작합니다. 이는 작업의 수명이 지속되는 동안 관련된 정보를 제공합니다. 이 오버로드는 콜백을 통해 해당 작업의 이벤트 처리기 ID에 대한 알림을 수신합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

public:
 IAsyncResult ^ BeginReceive(TimeSpan timeout, System::Object ^ stateObject, AsyncCallback ^ callback);
public IAsyncResult BeginReceive (TimeSpan timeout, object stateObject, AsyncCallback callback);
member this.BeginReceive : TimeSpan * obj * AsyncCallback -> IAsyncResult
Public Function BeginReceive (timeout As TimeSpan, stateObject As Object, callback As AsyncCallback) As IAsyncResult

매개 변수

timeout
TimeSpan

메시지를 사용할 수 있을 때까지 기다리는 시간 간격을 나타내는 TimeSpan입니다.

stateObject
Object

비동기 작업과 관련된 정보가 들어 있는 상태 개체이며 애플리케이션에서 지정합니다.

callback
AsyncCallback

비동기 작업 완료에 대한 알림을 수신할 AsyncCallback입니다.

반환

게시된 비동기 요청을 식별하는 IAsyncResult 입니다.

예외

timeout 매개 변수에 지정된 값이 잘못된 경우

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

예제

다음 코드 예제에서는 비동기 수신 작업을 만듭니다. 코드 예제에서는 로컬 메시지 큐에 메시지를 보낸 다음 를 호출BeginReceive(TimeSpan, Object, AsyncCallback)합니다. 은 10초의 제한 시간 값, 특정 메시지를 식별하는 고유 정수, 이벤트 처리기를 MyReceiveCompleted식별하는 의 AsyncCallback 새 instance 를 전달합니다. ReceiveCompleted 이벤트가 발생하면 이벤트 처리기가 메시지를 수신하고 메시지 본문과 정수 메시지 식별자를 화면에 씁니다.

#using <System.Messaging.dll>
#using <System.dll>

using namespace System;
using namespace System::Messaging;

// Creates a new queue.
void CreateQueue(String^ queuePath, bool transactional)
{
    if (!MessageQueue::Exists(queuePath))
    {
        MessageQueue^ queue = MessageQueue::Create(queuePath, transactional);
        queue->Close();       
    }
    else
    {
        Console::WriteLine("{0} already exists.", queuePath);
    }
}

// Provides an event handler for the ReceiveCompleted event.
void HandleReceiveCompleted(IAsyncResult^ asyncResult)
{
    // Connect to the queue.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // End the asynchronous receive operation.
    Message^ msg = queue->EndReceive(asyncResult);

    // Display the message information on the screen.
    Console::WriteLine("Message number: {0}", asyncResult->AsyncState);
    Console::WriteLine("Message body: {0}", msg->Body);

    queue->Close();
}

int main()
{
    // Represents a state object associated with each message.
    int messageNumber = 0;

    // Create a non-transactional queue on the local computer.
    // Note that the queue might not be immediately accessible, and
    // therefore this example might throw an exception of type
    // System.Messaging.MessageQueueException when trying to send a
    // message to the newly created queue.
    MessageQueue^ queue = nullptr;
    try
    {
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        queue = gcnew MessageQueue(".\\exampleQueue");

        // Send a message to the queue.
        queue->Send("Example Message");

        // Begin the asynchronous receive operation.
        queue->BeginReceive(TimeSpan::FromSeconds(10.0), messageNumber++,
            gcnew AsyncCallback(HandleReceiveCompleted));

        // Simulate doing other work on the current thread.
        System::Threading::Thread::Sleep(TimeSpan::FromSeconds(10.0));
    }
    catch (InvalidOperationException^)
    {
        Console::WriteLine("Please install Message Queuing.");
    }

    catch (MessageQueueException^ ex)
    {
        Console::WriteLine(ex->Message);
    }

    finally
    {   
        queue->Close();
    }
}

using System;
using System.Messaging;

public class QueueExample
{
    // Represents a state object associated with each message.
    static int messageNumber = 0;

    public static void Main()
    {
        // Create a non-transactional queue on the local computer.
        // Note that the queue might not be immediately accessible, and
        // therefore this example might throw an exception of type
        // System.Messaging.MessageQueueException when trying to send a
        // message to the newly created queue.
        CreateQueue(".\\exampleQueue", false);

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Send a message to the queue.
        queue.Send("Example Message");

        // Begin the asynchronous receive operation.
        queue.BeginReceive(TimeSpan.FromSeconds(10.0), messageNumber++,
            new AsyncCallback(MyReceiveCompleted));
            
        // Simulate doing other work on the current thread.
        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10.0));

        return;
    }

    // Creates a new queue.
    public static void CreateQueue(string queuePath, bool transactional)
    {
        if(!MessageQueue.Exists(queuePath))
        {
            MessageQueue.Create(queuePath, transactional);
        }
        else
        {
            Console.WriteLine(queuePath + " already exists.");
        }
    }

    // Provides an event handler for the ReceiveCompleted event.
    private static void MyReceiveCompleted(IAsyncResult asyncResult)
    {
        // Connect to the queue.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // End the asynchronous receive operation.
        Message msg = queue.EndReceive(asyncResult);

        // Display the message information on the screen.
        Console.WriteLine("Message number: {0}", (int)asyncResult.AsyncState);
        Console.WriteLine("Message body: {0}", (string)msg.Body);
    }
}

설명

이 오버로드를 사용하면 큐에서 메시지를 사용할 수 있게 되거나 지정된 시간 간격이 만료될 때 콜백 매개 변수에 지정된 콜백이 직접 호출됩니다. ReceiveCompleted 이벤트가 발생하지 않습니다. 의 BeginReceive 다른 오버로드는 이 구성 요소를 사용하여 이벤트를 발생합니다 ReceiveCompleted .

ReceiveCompleted 는 큐에 메시지가 이미 있는 경우에도 발생합니다.

를 사용 BeginReceive하려면 비동기 작업의 결과를 처리하고 이벤트 대리자와 연결하는 이벤트 처리기를 만듭니다. BeginReceive 는 비동기 수신 작업을 시작합니다. 는 MessageQueue 메시지가 큐에 도착할 때 이벤트 발생 ReceiveCompleted 을 통해 알림을 받습니다. 그런 다음 은 MessageQueue 를 사용하여 결과를 호출 EndReceive(IAsyncResult) 하거나 검색하여 메시지에 액세스할 수 있습니다 ReceiveCompletedEventArgs.

메서드는 BeginReceive 즉시 반환되지만 이벤트 처리기가 호출될 때까지 비동기 작업이 완료되지 않습니다.

BeginReceive 는 비동기이므로 현재 실행 스레드를 차단하지 않고 큐에서 메시지를 수신하도록 호출할 수 있습니다. 메시지를 동기적으로 받으려면 메서드를 Receive 사용합니다.

비동기 작업이 완료되면 이벤트 처리기에서 또는 BeginReceive 다시 호출 BeginPeek 하여 알림을 계속 받을 수 있습니다.

를 반환하는 BeginReceiveIAsyncResult 메서드가 시작한 비동기 작업을 식별합니다. 일반적으로 가 호출될 때까지 EndReceive(IAsyncResult) 는 사용하지 않지만 작업의 수명 동안 사용할 IAsyncResult 수 있습니다. 그러나 여러 비동기 작업을 시작하는 경우 해당 값을 배열에 배치 IAsyncResult 하고 모든 작업 또는 작업이 완료되기를 기다릴지 여부를 지정할 수 있습니다. 이 경우 의 속성을 IAsyncResult 사용하여 AsyncWaitHandle 완료된 작업을 식별합니다.

상태 개체는 작업과 상태 정보를 연결합니다. 예를 들어 여러 작업을 시작하기 위해 여러 번 호출 BeginReceive 하는 경우 정의하는 별도의 상태 개체를 통해 각 작업을 식별할 수 있습니다.

상태 개체를 사용하여 프로세스 스레드 간에 정보를 전달할 수도 있습니다. 스레드가 시작되었지만 콜백이 비동기 시나리오에서 다른 스레드에 있는 경우 상태 개체가 마샬링되고 이벤트의 정보와 함께 다시 전달됩니다.

트랜잭션과 함께 비동기 호출 BeginReceive 을 사용하지 마세요. 트랜잭션 비동기 작업을 수행하려면 를 호출 BeginPeek하고 피킹 작업을 위해 만든 이벤트 처리기 내에 트랜잭션 및 (동기) Receive 메서드를 배치합니다. 다음 C# 코드와 같이 이벤트 처리기에 기능이 포함될 수 있습니다.

myMessageQueue.BeginTransaction();
 myMessageQueue.Receive();
 myMessageQueue.CommitTransaction();

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

BeginReceive(TimeSpan, Cursor, Object, AsyncCallback)

지정된 제한 시간이 있고 지정된 커서 및 지정된 상태 개체를 사용하는 비동기 수신 작업을 초기화합니다. 상태 개체는 전체 작업 기간 동안 관련 정보를 제공합니다. 이 오버로드는 콜백을 통해 해당 작업의 이벤트 처리기 ID에 대한 알림을 수신합니다. 큐에서 메시지를 사용할 수 있거나 시간 초과가 발생할 때까지 작업이 완료되지 않습니다.

public:
 IAsyncResult ^ BeginReceive(TimeSpan timeout, System::Messaging::Cursor ^ cursor, System::Object ^ state, AsyncCallback ^ callback);
public IAsyncResult BeginReceive (TimeSpan timeout, System.Messaging.Cursor cursor, object state, AsyncCallback callback);
member this.BeginReceive : TimeSpan * System.Messaging.Cursor * obj * AsyncCallback -> IAsyncResult
Public Function BeginReceive (timeout As TimeSpan, cursor As Cursor, state As Object, callback As AsyncCallback) As IAsyncResult

매개 변수

timeout
TimeSpan

메시지를 사용할 수 있을 때까지 기다리는 시간 간격을 나타내는 TimeSpan입니다.

cursor
Cursor

메시지 큐에서 특정 위치를 유지하는 Cursor입니다.

state
Object

비동기 작업과 관련된 정보가 들어 있는 상태 개체이며 애플리케이션에서 지정합니다.

callback
AsyncCallback

비동기 작업 완료에 대한 알림을 수신하는 AsyncCallback입니다.

반환

게시된 비동기 요청을 식별하는 IAsyncResult 입니다.

예외

cursor 매개 변수가 null인 경우

timeout 매개 변수에 지정된 값이 잘못된 경우

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

설명

이 오버로드를 사용하면 큐에서 메시지를 사용할 수 있게 되거나 지정된 시간 간격이 만료될 때 콜백 매개 변수에 지정된 콜백이 직접 호출됩니다. ReceiveCompleted 이벤트가 발생하지 않습니다. 의 BeginReceive 다른 오버로드는 이 구성 요소를 사용하여 이벤트를 발생합니다 ReceiveCompleted .

ReceiveCompleted 는 큐에 메시지가 이미 있는 경우에도 발생합니다.

를 사용 BeginReceive하려면 비동기 작업의 결과를 처리하고 이벤트 대리자와 연결하는 이벤트 처리기를 만듭니다. BeginReceive 는 비동기 수신 작업을 시작합니다. 는 MessageQueue 메시지가 큐에 도착할 때 이벤트 발생 ReceiveCompleted 을 통해 알림을 받습니다. 그런 다음 은 MessageQueue 를 사용하여 결과를 호출 EndReceive(IAsyncResult) 하거나 검색하여 메시지에 액세스할 수 있습니다 ReceiveCompletedEventArgs.

메서드는 BeginReceive 즉시 반환되지만 이벤트 처리기가 호출될 때까지 비동기 작업이 완료되지 않습니다.

BeginReceive 는 비동기이므로 현재 실행 스레드를 차단하지 않고 큐에서 메시지를 수신하도록 호출할 수 있습니다. 메시지를 동기적으로 받으려면 메서드를 Receive 사용합니다.

비동기 작업이 완료되면 이벤트 처리기에서 또는 BeginReceive 다시 호출 BeginPeek 하여 알림을 계속 받을 수 있습니다.

를 반환하는 BeginReceiveIAsyncResult 메서드가 시작한 비동기 작업을 식별합니다. 일반적으로 가 호출될 때까지 EndReceive(IAsyncResult) 는 사용하지 않지만 작업의 수명 동안 사용할 IAsyncResult 수 있습니다. 그러나 여러 비동기 작업을 시작하는 경우 해당 값을 배열에 배치 IAsyncResult 하고 모든 작업 또는 작업이 완료되기를 기다릴지 여부를 지정할 수 있습니다. 이 경우 의 속성을 IAsyncResult 사용하여 AsyncWaitHandle 완료된 작업을 식별합니다.

상태 개체는 작업과 상태 정보를 연결합니다. 예를 들어 여러 작업을 시작하기 위해 여러 번 호출 BeginReceive 하는 경우 정의하는 별도의 상태 개체를 통해 각 작업을 식별할 수 있습니다.

상태 개체를 사용하여 프로세스 스레드 간에 정보를 전달할 수도 있습니다. 스레드가 시작되었지만 콜백이 비동기 시나리오에서 다른 스레드에 있는 경우 상태 개체가 마샬링되고 이벤트의 정보와 함께 다시 전달됩니다.

트랜잭션과 함께 비동기 호출 BeginReceive 을 사용하지 마세요. 트랜잭션 비동기 작업을 수행하려면 를 호출 BeginPeek하고 피킹 작업을 위해 만든 이벤트 처리기 내에 트랜잭션 및 (동기) Receive 메서드를 배치합니다. 다음 C# 코드와 같이 이벤트 처리기에 기능이 포함될 수 있습니다.

myMessageQueue.BeginTransaction();
 myMessageQueue.Receive();
 myMessageQueue.CommitTransaction();

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 Yes
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 Yes

추가 정보

적용 대상

스레드 보안

메서드가 스레드로부터 안전하지 않습니다.