Freigeben über


InterfaceQueuingAttribute-Klasse

Aktiviert Warteschlangenunterstützung für die markierte Schnittstelle. Diese Klasse kann nicht vererbt werden.

Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)

Syntax

'Declaration
<ComVisibleAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=True, AllowMultiple:=True)> _
Public NotInheritable Class InterfaceQueuingAttribute
    Inherits Attribute
'Usage
Dim instance As InterfaceQueuingAttribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, Inherited=true, AllowMultiple=true)] 
public sealed class InterfaceQueuingAttribute : Attribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, Inherited=true, AllowMultiple=true)] 
public ref class InterfaceQueuingAttribute sealed : public Attribute
/** @attribute ComVisibleAttribute(false) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, Inherited=true, AllowMultiple=true) */ 
public final class InterfaceQueuingAttribute extends Attribute
ComVisibleAttribute(false) 
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, Inherited=true, AllowMultiple=true) 
public final class InterfaceQueuingAttribute extends Attribute

Hinweise

Aufrufe dieser Schnittstelle werden mithilfe von Message Queuing in einer Warteschlange gespeichert.

Um eine Schnittstelle als in eine Warteschlange eingereiht zu kennzeichnen, wenden Sie dieses Attribut mit folgender Syntax auf die Schnittstelle an: [InterfaceQueuing].

Die Membermethoden einer Schnittstelle in einer Warteschlange müssen den Anforderungen an Methodenaufrufe in einer Warteschlange entsprechen. So dürfen sie z. B. keinen out-Parameter und keinen ref-Parameter aufweisen.

Weitere Informationen über das Verwenden von Attributen finden Sie unter Erweitern von Metadaten mithilfe von Attributen.

Beispiel

Im folgenden Codebeispiel wird die Verwendung des InterfaceQueuingAttribute-Attributs veranschaulicht.

public interface IQueuedComponent
{
    void QueuedTask();
}
// Mark IQueuedComponent interface as queued
[InterfaceQueuing(true, Interface="IQueuedComponent")]
// Create the queued component class by inheriting the 
// System.EnterpriseServices.ServicedComponent class and an
// interface that is marked as queued with the InterfaceQueuing attribute
public class QueuedComponent : ServicedComponent, IQueuedComponent
{
    public void QueuedTask()
    {
        // Perform queued task here
    }
}
public interface class IQueuedComponent
{
   void QueuedTask();
};


// Mark IQueuedComponent interface as queued
// Create the queued component class by inheriting the 
// System.EnterpriseServices.ServicedComponent class and an
// interface that is marked as queued with the InterfaceQueuing attribute

[InterfaceQueuing(true,Interface="IQueuedComponent")]
public ref class QueuedComponent sealed: public ServicedComponent, public IQueuedComponent
{
public:
   virtual void QueuedTask()
   {
      // Perform queued task here
   }

};

Im folgenden Codebeispiel wird veranschaulicht, wie eine COM+-Anwendung zur Kompilierungszeit mithilfe des ApplicationQueuing-Attributs als in eine Warteschlange eingereiht gekennzeichnet und der COM+-Listener durch Festlegen von QueueListenerEnabled auf true aktiviert wird.

// Mark the COM+ application as queued at compile time by using the 
// ApplicationQueuing attribute. Enable the COM+ listener by 
// setting the QueueListenerEnabled to true
[assembly: ApplicationQueuing(Enabled=true, QueueListenerEnabled=true)]
// Mark the COM+ application as queued at compile time by using the 
// ApplicationQueuing attribute. Enable the COM+ listener by 
// setting the QueueListenerEnabled to true
[assembly:ApplicationQueuing(Enabled=true,QueueListenerEnabled=true)];

Im folgenden Codebeispiel wird veranschaulicht, wie BindToMoniker verwendet wird, um den Moniker in der Warteschlange auszuführen, eine Aufzeichnungsinstanz abzurufen, die aufzuzeichnende Methode aufzurufen und die Freigabe des Aufzeichnungsobjekts zu erzwingen, damit die Methode in die Warteschlange eingereiht wird.

// Use BindToMoniker to run the queued moniker, to get an instance of the recorder
IQueuedComponent qc = 
    (IQueuedComponent)System.Runtime.InteropServices.Marshal.BindToMoniker("queue:/new:QueuedComponent");
// Call the method that will be recorded
qc.QueuedTask();

// Force the release of the recorder object, to send the message to the queue
System.Runtime.InteropServices.Marshal.ReleaseComObject(qc);
// Use BindToMoniker to run the queued moniker, to get an instance of the recorder
IQueuedComponent ^ qc = dynamic_cast<IQueuedComponent^>(System::Runtime::InteropServices::Marshal::BindToMoniker( "queue:/new:QueuedComponent" ));

// Call the method that will be recorded
qc->QueuedTask();

// Force the release of the recorder object, to send the message to the queue
System::Runtime::InteropServices::Marshal::ReleaseComObject( qc );

Vererbungshierarchie

System.Object
   System.Attribute
    System.EnterpriseServices.InterfaceQueuingAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

InterfaceQueuingAttribute-Member
System.EnterpriseServices-Namespace