コード例 #1
0
        private void ShutdownContactSubscription(AsyncTask task, object state)
        {
            if (m_contactGroupServices.CurrentState != CollaborationSubscriptionState.Subscribed)
            {
                task.Complete(null);
                return;
            }
            m_contactGroupServices.NotificationReceived -= this.ContactGroupServices_NotificationReceived;

            task.DoOneStep(
                delegate()
            {
                Logger.Log(Logger.LogLevel.Info, "Starting contact unsubscription.");
                m_contactGroupServices.BeginUnsubscribe(
                    delegate(IAsyncResult ar)
                {
                    task.DoFinalStep(
                        delegate()
                    {
                        m_contactGroupServices.EndUnsubscribe(ar);
                        Logger.Log(Logger.LogLevel.Info, "Started contact unsubscription.");
                    });
                },
                    null);
            });
        }
コード例 #2
0
        // Callback method referred to in the call to BeginUnsubscribe on the ContactGroupServices instance.
        private void ContactGroupUnsubscribeCB(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndUnsubscribe(ar);
            }

            // A production application should have catch blocks for a number
            // of other exceptions, including InvalidOperationException and PublishSubscribeException.
            catch (RealTimeException exception)
            {
                Console.WriteLine("Contact Group Unsubscription failed due to exception: {0}",
                                  exception.ToString());
            }
        }