当前位置: 首页>>代码示例>>C#>>正文


C# Subscription.SetState方法代码示例

本文整理汇总了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);
            }

        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:58,代码来源:ComAeProxy.cs


注:本文中的Subscription.SetState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。