StopPublishingMessage() public méthode

public StopPublishingMessage ( [ messageId ) : void
messageId [
Résultat void
        private void PublishMessageButton_Click(object sender, RoutedEventArgs e)
        {
            if (proximityDevice == null)
            {
                proximityDevice = ProximityDevice.GetDefault();
            }

            // Make sure NFC is supported
            if (proximityDevice != null)
            {
                // Stop publishing the current message.
                if (publishedMessageId != -1)
                {
                    proximityDevice.StopPublishingMessage(publishedMessageId);
                }

                // Publish the new one
                publishedMessageId = proximityDevice.PublishMessage("Windows.JumpstartMessageType", MessageTextBox.Text,
                                                                    new MessageTransmittedHandler((s, args) => Dispatcher.BeginInvoke(() => MessageBox.Show("Message transmitted!")))
                                                                    );
            }
        }
Exemple #2
0
 protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     if (_proximityDevice != null)
     {
         if (_publishedMessageId != -1)
         {
             _proximityDevice.StopPublishingMessage(_publishedMessageId);
             _publishedMessageId = -1;
         }
         if (_subscribedMessageId != -1)
         {
             _proximityDevice.StopSubscribingForMessage(_subscribedMessageId);
             _subscribedMessageId = 1;
         }
     }
 }