From 87e9006186fadd5897d2d2d6d94af65070c78426 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Tue, 29 Apr 2014 17:21:07 +0900 Subject: [PATCH] =?utf8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3=E3=83=BC?= =?utf8?q?=E3=83=AB=E6=83=85=E5=A0=B1=E3=81=AE=E5=A4=89=E6=9B=B4=E5=87=A6?= =?utf8?q?=E7=90=86=E3=82=92BackgroundWorker=E3=81=8B=E3=82=89Task?= =?utf8?q?=E3=81=AB=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/ShowUserInfo.cs | 54 +++++++++-------------------------------------- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/OpenTween/ShowUserInfo.cs b/OpenTween/ShowUserInfo.cs index d5cfef1c..507b87c8 100644 --- a/OpenTween/ShowUserInfo.cs +++ b/OpenTween/ShowUserInfo.cs @@ -491,33 +491,6 @@ namespace OpenTween UserPicture.Cursor = Cursors.Default; } - private class UpdateProfileArgs - { - public Twitter tw; - public string name; - public string location; - public string url; - public string description; - } - - private void UpdateProfile_Dowork(object sender, DoWorkEventArgs e) - { - UpdateProfileArgs arg = (UpdateProfileArgs)e.Argument; - e.Result = arg.tw.PostUpdateProfile(arg.name, - arg.url, - arg.location, - arg.description); - } - - private void UpddateProfile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - string res = (string)e.Result; - if (res.StartsWith("err:", StringComparison.CurrentCultureIgnoreCase)) - { - MessageBox.Show(res); - } - } - private bool IsEditing = false; private string ButtonEditText = ""; @@ -560,29 +533,22 @@ namespace OpenTween } else { - UpdateProfileArgs arg = new UpdateProfileArgs(); - if (TextBoxName.Modified || TextBoxLocation.Modified || TextBoxWeb.Modified || TextBoxDescription.Modified) { - arg.tw = this.Twitter; - arg.name = TextBoxName.Text.Trim(); - arg.url = TextBoxWeb.Text.Trim(); - arg.location = TextBoxLocation.Text.Trim(); - arg.description = TextBoxDescription.Text.Trim(); - - using (FormInfo dlg = new FormInfo(this, Properties.Resources.UserInfoButtonEdit_ClickText2, - UpdateProfile_Dowork, - UpddateProfile_RunWorkerCompleted, - arg)) + var err = await Task.Run(() => + this.Twitter.PostUpdateProfile( + this.TextBoxName.Text, + this.TextBoxWeb.Text, + this.TextBoxLocation.Text, + this.TextBoxDescription.Text)); + + if (!string.IsNullOrEmpty(err)) { - dlg.ShowDialog(); - if (!string.IsNullOrEmpty(dlg.Result.ToString())) - { - return; - } + MessageBox.Show(err); + return; } } -- 2.11.0