StopPublishingMessage() public method

public StopPublishingMessage ( [ messageId ) : void
messageId [
return 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!")))
                                                                    );
            }
        }
Beispiel #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;
         }
     }
 }