mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 10:46:57 +13:00
Retrieve JIRA issue summary async to not block UI
This commit is contained in:
parent
53bbeece19
commit
31d4a11795
1 changed files with 20 additions and 7 deletions
|
@ -31,7 +31,9 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
namespace UploadersLib.GUI
|
namespace UploadersLib.GUI
|
||||||
{
|
{
|
||||||
public partial class JiraUpload : Form
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public partial class JiraUpload : Form
|
||||||
{
|
{
|
||||||
public delegate string GetSummaryHandler(string issueId);
|
public delegate string GetSummaryHandler(string issueId);
|
||||||
|
|
||||||
|
@ -64,10 +66,10 @@ public JiraUpload(string issuePrefix, GetSummaryHandler getSummary)
|
||||||
|
|
||||||
private void JiraUpload_Load(object sender, EventArgs e)
|
private void JiraUpload_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
UpdateSummary(null);
|
||||||
|
|
||||||
txtIssueId.Text = _issuePrefix;
|
txtIssueId.Text = _issuePrefix;
|
||||||
txtIssueId.SelectionStart = txtIssueId.Text.Length;
|
txtIssueId.SelectionStart = txtIssueId.Text.Length;
|
||||||
|
|
||||||
ValidateIssueId(txtIssueId.Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||||
|
@ -83,11 +85,22 @@ private void btnSend_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
private void ValidateIssueId(string issueId)
|
private void ValidateIssueId(string issueId)
|
||||||
{
|
{
|
||||||
var res = _getSummary(issueId);
|
Task.Factory
|
||||||
btnUpload.Enabled = (res != null);
|
.StartNew(() => _getSummary(issueId))
|
||||||
|
.ContinueWith(UpdateSummaryAsync);
|
||||||
|
}
|
||||||
|
|
||||||
lblSummary.Text = res ?? Resources.JiraUpload_ValidateIssueId_Issue_not_found;
|
private void UpdateSummaryAsync(Task<string> task)
|
||||||
lblSummary.Enabled = res != null;
|
{
|
||||||
|
this.Invoke((Action)(() => UpdateSummary(task.Result)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSummary(string summary)
|
||||||
|
{
|
||||||
|
btnUpload.Enabled = (summary != null);
|
||||||
|
|
||||||
|
lblSummary.Text = summary ?? Resources.JiraUpload_ValidateIssueId_Issue_not_found;
|
||||||
|
lblSummary.Enabled = summary != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
private void btnCancel_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue