/// <summary>
        /// Makes an asynchronous DELETE request to the Facebook server.
        /// </summary>
        /// <param name="facebookClient">The facebook client.</param>
        /// <param name="path">The resource path.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The task of the result.</returns>
        public static Task <object> DeleteTaskAsync(this FacebookClient facebookClient, string path, IDictionary <string, object> parameters)
        {
            Contract.Requires(!(string.IsNullOrEmpty(path) && parameters == null));

            var tcs = CreateSource <object>(null);

            EventHandler <FacebookApiEventArgs> handler = null;

            handler = (sender, e) => TransferCompletionToTask <object>(tcs, e, () => e.GetResultData(), () => facebookClient.DeleteCompleted -= handler);

            facebookClient.DeleteCompleted += handler;

            try
            {
                facebookClient.DeleteAsync(path, parameters, tcs);
            }
            catch
            {
                facebookClient.DeleteCompleted -= handler;
                tcs.TrySetCanceled();
                throw;
            }

            return(tcs.Task);
        }
        private void DeleteLastMessage_Click(object sender, RoutedEventArgs e)
        {
            btnDeleteLastMessage.IsEnabled = false;

            var fb = new FacebookClient(_accessToken);

            // make sure to add event handler for DeleteCompleted.
            fb.DeleteCompleted += (o, args) =>
            {
                // incase you support cancellation, make sure to check
                // e.Cancelled property first even before checking (e.Error!=null).
                if (args.Cancelled)
                {
                    // for this example, we can ignore as we don't allow this
                    // example to be cancelled.

                    // you can check e.Error for reasons behind the cancellation.
                    var cancellationError = args.Error;
                }
                else if (args.Error != null)
                {
                    // error occurred
                    Dispatcher.BeginInvoke(
                        () =>
                        {
                            MessageBox.Show(args.Error.Message);
                        });
                }
                else
                {
                    // the request was completed successfully

                    // make sure to be on the right thread when working with ui.
                    Dispatcher.BeginInvoke(() =>
                                               {
                                                   MessageBox.Show("Message deleted successfully");
                                                   btnDeleteLastMessage.IsEnabled = false;
                                               });
                }
            };

            fb.DeleteAsync(_lastMessageId);
        }
        private void DeleteLastMessage_Click(object sender, RoutedEventArgs e)
        {
            btnDeleteLastMessage.IsEnabled = false;

            var fb = new FacebookClient(_accessToken);

            fb.DeleteCompleted += (o, args) =>
            {
                if (args.Error != null)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                    return;
                }

                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show("Message deleted successfully");
                    btnDeleteLastMessage.IsEnabled = false;
                });
            };

            fb.DeleteAsync(_lastMessageId);
        }
        /// <summary>
        /// Delete post from wall of facebook user
        /// </summary>
        public void DeletePost()
        {
            var fb = new FacebookClient(_accessToken);

            fb.DeleteCompleted += (o, args) =>
                                      {
                                          if (args.Error != null)
                                          {
                                              Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                                              return;
                                          }

                                          Dispatcher.BeginInvoke(() =>
                                                                     {
                                                                         MessageBox.Show("Message deleted successfully");
                                                                         btnDeletePost.IsEnabled = false;
                                                                     });
                                      };

            fb.DeleteAsync(_lastMessageId);  // delete message from wall
        }