本文整理汇总了C#中Subscription.SetState方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.SetState方法的具体用法?C# Subscription.SetState怎么用?C# Subscription.SetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription.SetState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEventSubscription
/// <summary>
/// Add an Event Subscription object to an Event Server
/// </summary>
/// <param name="bActive">FALSE if the Event Subscription is to be created inactive and TRUE if it is to be created as active.</param>
/// <param name="dwBufferTime">The requested buffer time. The buffer time is in milliseconds and tells the server how often to send event notifications. A value of 0 for dwBufferTime means that the server should send event notifications as soon as it gets them.</param>
/// <param name="dwMaxSize">The requested maximum number of events that will be sent in a single IOPCEventSink::OnEvent callback. A value of 0 means that there is no limit to the number of events that will be sent in a single callback.</param>
/// <param name="hClientSubscription">Client provided handle for this event subscription.</param>
/// <param name="riid">The type of interface desired</param>
/// <param name="ppUnk">Where to store the returned interface pointer.</param>
/// <param name="pdwRevisedBufferTime">The buffer time that the server is actually providing, which may differ from dwBufferTime.</param>
/// <param name="pdwRevisedMaxSize">The maximum number of events that the server will actually be sending in a single IOPCEventSink::OnEvent callback, which may differ from dwMaxSize.</param>
public void CreateEventSubscription(int bActive, int dwBufferTime, int dwMaxSize, int hClientSubscription, ref Guid riid, out object ppUnk, out int pdwRevisedBufferTime, out int pdwRevisedMaxSize)
{
ppUnk = IntPtr.Zero;
pdwRevisedBufferTime = 0;
pdwRevisedMaxSize = 0;
IntPtr pbActive = IntPtr.Zero;
IntPtr pdwBufferTime = IntPtr.Zero;
IntPtr pdwMaxSize = IntPtr.Zero;
Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
try
{
Subscription subscription = new Subscription(this);
if (subscription == null)
throw ComUtils.CreateComException("E_OUTOFMEMORY", ResultIds.E_OUTOFMEMORY);
SubscriptionListInsert(subscription);
pbActive = Marshal.AllocHGlobal(Marshal.SizeOf(bActive.GetType()));
pdwBufferTime = Marshal.AllocHGlobal(Marshal.SizeOf(dwBufferTime.GetType()));
pdwMaxSize = Marshal.AllocHGlobal(Marshal.SizeOf(dwMaxSize.GetType()));
Marshal.WriteInt32(pbActive, bActive);
Marshal.WriteInt32(pdwBufferTime, dwBufferTime);
Marshal.WriteInt32(pdwMaxSize, dwMaxSize);
subscription.SetState(pbActive, pdwBufferTime, pdwMaxSize, hClientSubscription, out pdwRevisedBufferTime, out pdwRevisedMaxSize);
subscription.UaSubscription = m_Subscription;
ppUnk = subscription;
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error in CreateEventSubscription");
throw ComUtils.CreateComException(e);
}
finally
{
if (pbActive != IntPtr.Zero)
Marshal.FreeHGlobal(pbActive);
if (pdwBufferTime != IntPtr.Zero)
Marshal.FreeHGlobal(pdwBufferTime);
if (pdwMaxSize != IntPtr.Zero)
Marshal.FreeHGlobal(pdwMaxSize);
}
}