InterfaceQueuingAttribute Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Включает поддержку очереди для помеченного интерфейса. Этот класс не наследуется.
public ref class InterfaceQueuingAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class InterfaceQueuingAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type InterfaceQueuingAttribute = class
inherit Attribute
Public NotInheritable Class InterfaceQueuingAttribute
Inherits Attribute
- Наследование
- Атрибуты
Примеры
В следующем примере кода показано, как использовать InterfaceQueuingAttribute атрибут.
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
}
};
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
}
}
В следующем примере кода показано, как пометить приложение COM+ как в очереди во время компиляции с помощью атрибута ApplicationQueuing и включить прослушиватель COM+, задав 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)];
// 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)]
В следующем примере кода показано, как использовать BindToMoniker для запуска моникера в очереди, получения экземпляра записывателя, вызова метода, который будет записан, и принудительного выпуска объекта средства записи для отправки сообщения в очередь.
// 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 );
// 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);
Комментарии
Вызовы этого интерфейса будут помещены в очередь с помощью очереди сообщений.
Чтобы пометить интерфейс как в очереди, примените этот атрибут к интерфейсу с помощью следующего синтаксиса: [InterfaceQueuing]
Методы-члены интерфейса очереди должны соответствовать требованиям для вызовов в очереди, таких как отсутствие out или ref параметры.
Дополнительные сведения об использовании атрибутов см. в разделе "Атрибуты".
Конструкторы
| Имя | Описание |
|---|---|
| InterfaceQueuingAttribute() |
Инициализирует новый экземпляр InterfaceQueuingAttribute класса, задающий Enabled значения по умолчанию и Interface свойства. |
| InterfaceQueuingAttribute(Boolean) |
Инициализирует новый экземпляр InterfaceQueuingAttribute класса, при необходимости отключая поддержку очереди. |
Свойства
| Имя | Описание |
|---|---|
| Enabled |
Возвращает или задает значение, указывающее, включена ли поддержка очереди. |
| Interface |
Возвращает или задает имя интерфейса, в котором включена очередь. |
| TypeId |
При реализации в производном классе получает уникальный идентификатор для этого Attribute. (Унаследовано от Attribute) |
Методы
| Имя | Описание |
|---|---|
| Equals(Object) |
Возвращает значение, указывающее, равен ли этот экземпляр указанному объекту. (Унаследовано от Attribute) |
| GetHashCode() |
Возвращает хэш-код для этого экземпляра. (Унаследовано от Attribute) |
| GetType() |
Возвращает Type текущего экземпляра. (Унаследовано от Object) |
| IsDefaultAttribute() |
При переопределении в производном классе указывает, является ли значение этого экземпляра значением по умолчанию для производного класса. (Унаследовано от Attribute) |
| Match(Object) |
При переопределении в производном классе возвращает значение, указывающее, равен ли этот экземпляр указанному объекту. (Унаследовано от Attribute) |
| MemberwiseClone() |
Создает неглубокую копию текущей Object. (Унаследовано от Object) |
| ToString() |
Возвращает строку, представляющую текущий объект. (Унаследовано от Object) |
Явные реализации интерфейса
| Имя | Описание |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Сопоставляет набор имен соответствующему набору идентификаторов диспетчеризации. (Унаследовано от Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Извлекает сведения о типе объекта, который можно использовать для получения сведений о типе для интерфейса. (Унаследовано от Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Возвращает количество предоставляемых объектом интерфейсов для доступа к сведениям о типе (0 или 1). (Унаследовано от Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Предоставляет доступ к свойствам и методам, предоставляемым объектом. (Унаследовано от Attribute) |