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


C# HttpNotificationChannel.Close方法代码示例

本文整理汇总了C#中HttpNotificationChannel.Close方法的典型用法代码示例。如果您正苦于以下问题:C# HttpNotificationChannel.Close方法的具体用法?C# HttpNotificationChannel.Close怎么用?C# HttpNotificationChannel.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpNotificationChannel的用法示例。


在下文中一共展示了HttpNotificationChannel.Close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button_Click_1

 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     httpChannel = HttpNotificationChannel.Find(channelName);
     //如果存在就删除
     if (httpChannel != null)
     {
         httpChannel.Close();
         httpChannel.Dispose();
     }
     httpChannel = new HttpNotificationChannel(channelName, "NotificationServer");
     httpChannel.ChannelUriUpdated += httpChannel_ChannelUriUpdated;
     httpChannel.ShellToastNotificationReceived += httpChannel_ShellToastNotificationReceived;
     httpChannel.HttpNotificationReceived += httpChannel_HttpNotificationReceived;
     httpChannel.ErrorOccurred += httpChannel_ErrorOccurred;
     httpChannel.Open();
     httpChannel.BindToShellToast();
     httpChannel.BindToShellTile();
 }
开发者ID:peepo3663,项目名称:WindowsPhone8,代码行数:18,代码来源:MainPage.xaml.cs

示例2: UpdateLiveTile

        public void UpdateLiveTile(Uri liveTileUri, string liveTileTitle, int? liveTileCount, Action onComplete)
        {
            HttpNotificationChannel toastChannel = HttpNotificationChannel.Find("liveTileChannel");
            if (toastChannel != null)
            {
                toastChannel.Close();
            }

            toastChannel = new HttpNotificationChannel("liveTileChannel");


            toastChannel.ChannelUriUpdated +=
                (s, e) =>
                {
                    Debug.WriteLine(String.Format("Is image an absolute Uri: {0}", tileSchedule.RemoteImageUri.IsAbsoluteUri));
                    if (liveTileUri.IsAbsoluteUri)
                    {
                        toastChannel.BindToShellTile(new Collection<Uri> { liveTileUri });
                    }
                    else
                    {
                        toastChannel.BindToShellTile();
                    }

                    SendTileToPhone(e.ChannelUri, liveTileUri.ToString(), liveTileCount, liveTileTitle,
                                () =>
                                {
                                    //Give it some time to let the update propagate
                                    Thread.Sleep(TimeSpan.FromSeconds(10));

                                    toastChannel.UnbindToShellTile();
                                    toastChannel.Close();

                                    //Call the "complete" delegate
                                    if (onComplete != null)
                                        onComplete();
                                }
                        );
                };
            toastChannel.Open();
        }
开发者ID:awayo,项目名称:AUWP7,代码行数:41,代码来源:InstantLiveTileUpdateHelper.cs

示例3: totalArrangement

        //============================= 推送通知相关变量

        public totalArrangement()
        {
            InitializeComponent();

            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("No network connection available!");
                return;
            }

            showCurrentlist();
            sendPosition();
           

            //新添加的接收 推送信息的 

            httpChannel = HttpNotificationChannel.Find(channelName);
            if (httpChannel != null)
            {
                httpChannel.Close();
                httpChannel.Dispose();
            }

            httpChannel = new HttpNotificationChannel(channelName, "NotificationServer");

            //注册URI
            httpChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(httpChannel_ChannelUriUpdated);

            //发生错误的事件
            httpChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(httpChannel_ErrorOccurred);

            //toast 推送通知服务事件
            httpChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);

            //打开连接
            httpChannel.Open();
            //绑定toast 推送服务
            httpChannel.BindToShellToast();


        }
开发者ID:whuacn,项目名称:echelper,代码行数:43,代码来源:totalArrangement.xaml.cs

示例4: CloseChannel

 private void CloseChannel(HttpNotificationChannel channel)
 {
     try
     {
         if (channel != null)
             channel.Close();
     }
     catch { }
 }
开发者ID:appacitive,项目名称:appacitive-dotnet-sdk,代码行数:9,代码来源:SingletonPushChannel.cs

示例5: PushChannel_ErrorOccurred

        /// <summary>
        /// Event handler for when a push notification error occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PushChannel_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e)
        {
            Utils.Tools.LogException((String.Format("A push notification {0} error occurred.  {1} ({2}) {3}",
               e.ErrorType, e.Message, e.ErrorCode, e.ErrorAdditionalData)), null);

            if (processingError)
                return;

            processingError = true;
            switch (e.ErrorType)
            {
                case ChannelErrorType.ChannelOpenFailed:
                case ChannelErrorType.PayloadFormatError:

                    //ChannelErrorType.ChannelOpenFailed
                    //This error is returned when the Push Client and the Push Notification Service are unable to establish a connection

                    //ChannelErrorType.PayloadFormatError:
                    //This error is returned when the XML payload format or the HTTP header of the push notification is syntactically invalid.

                    pushChannel = HttpNotificationChannel.Find(channelName);

                    try
                    {
                        if (pushChannel != null)
                        {
                            pushChannel.Close();
                            pushChannel.Dispose();
                            pushChannel = null;
                        }
                    }
                    catch (InvalidOperationException ioException)
                    {
                        Utils.Tools.LogException("Cannot close the channel", ioException);
                    }
                    catch (ArgumentException argEcxeption)
                    {
                        Utils.Tools.LogException("Cannot close the channel", argEcxeption);
                    }
                 /*   UIThread.Invoke(() =>
                    {
                        this.enablePushNotifications();
                    });*/
                    break;
                case ChannelErrorType.NotificationRateTooHigh:
                    //This error is returned when the Push Client is unable to receive messages because the web service is sending too many messages at too quick a rate to a certain device.
                    //Slow down the notifications
                    //@TODO: send the server a signal?
                    break;
                case ChannelErrorType.MessageBadContent:
                    //This error is returned when the image reference is pointing to an HTTP image, even though the notification channel is not currently bound to a list of URIs.
                    //This should never happen to us
                    break;
                case ChannelErrorType.PowerLevelChanged:
                    //This has been deprecated because push client no longer takes any action based on any power states
                    break;
                case ChannelErrorType.Unknown:
                    //An internal error has occurred and could not be recovered. A device reboot may be necessary.
                    break;
                default:
                    break;
            }

            processingError = false;
        }
开发者ID:timextreasures,项目名称:WordPress-WindowsPhone,代码行数:70,代码来源:PushNotificationsHelper.cs

示例6: disablePushNotifications

 public void disablePushNotifications()
 {
     try
     {
         // Try to find the push channel.
         pushChannel = HttpNotificationChannel.Find(channelName);
         if (pushChannel != null)
         {
             pushChannel.Close();
             pushChannel.Dispose();
             pushChannel = null;
         }
     }
     catch (InvalidOperationException ioException)
     {
         Utils.Tools.LogException("Cannot close the channel", ioException);
     }
     catch (ArgumentException argEcxeption)
     {
         Utils.Tools.LogException("Cannot close the channel", argEcxeption);
     }
     this.UnregisterDevice();
 }
开发者ID:timextreasures,项目名称:WordPress-WindowsPhone,代码行数:23,代码来源:PushNotificationsHelper.cs

示例7: getUri

        // ===========================这个是推送发的信息




        //====================下面是推送 Uri
        private void getUri()
        {
            httpChannel = HttpNotificationChannel.Find(channelName);
             if (httpChannel != null)
            {
                httpChannel.Close();
                httpChannel.Dispose();
            }

            httpChannel = new HttpNotificationChannel(channelName, "NotificationServer");

            //注册URI
            httpChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(httpChannel_ChannelUriUpdated);

            //发生错误的事件
            httpChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(httpChannel_ErrorOccurred);

            //toast 推送通知服务事件
            httpChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);

            //打开连接
            httpChannel.Open();
            //绑定toast 推送服务
            httpChannel.BindToShellToast();
        }
开发者ID:whuacn,项目名称:echelper,代码行数:31,代码来源:totalArrangement.xaml.cs


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