示例#1
0
        private async Task SendTweet()
        {
            IsSending = true;

            var textToTweet = Text;

            if (QuotedTweet != null)
            {
                textToTweet += " " + QuotedTweet.Model.GetUrl().AbsoluteUri;
            }

            await Task.Run(async() =>
            {
                ulong inReplyToId = InReplyTo?.Id ?? 0;

                foreach (var acc in Accounts.Where(a => a.Use))
                {
                    await acc.Context.Twitter.TweetAsync(textToTweet, Medias.Select(m => m.MediaID), inReplyToId).ConfigureAwait(false);
                }
            }).ContinueWith(async t =>
            {
                IsSending = false;
                await Dispatcher.RunAsync(async() =>
                {
                    if (!StayOpen)
                    {
                        Close(true);
                    }

                    await OnLoad(null);
                });
            });
        }
示例#2
0
        private async Task <List <Tuple <ulong, ulong> > > SendTweet()
        {
            var textToTweet = Text;

            if (QuotedTweet != null)
            {
                textToTweet += " " + QuotedTweet.Model.GetUrl().AbsoluteUri;
            }

            var result = new List <Tuple <ulong, ulong> >();

            await Task.Run(async() =>
            {
                ulong inReplyToId = InReplyTo?.Id ?? 0;

                foreach (var acc in Accounts.Where(a => a.Use))
                {
                    var status = await
                                 acc.Context.Twitter.Statuses.TweetAsync(textToTweet, Medias.Select(m => m.MediaID), inReplyToId)
                                 .ConfigureAwait(false);

                    result.Add(new Tuple <ulong, ulong>(status.ID, acc.Context.UserId));
                }
            }).ContinueWith(async t =>
            {
                if (t.IsFaulted)
                {
                    Notifier.DisplayMessage(t.Exception?.GetReason(), NotificationType.Error);
                    return;
                }

                await CloseOrReload();
            }).ContinueWith(t => { IsSending = false; });

            return(result);
        }