I need to create a Dev Studio extension which allows issues to be create in Gitlab.
Several combo boxes are loaded and then the user hits a button and the issue is created.
The calling code looks like:
private void IssueCreator_Click(object sender, RoutedEventArgs e)
{
var res = CreateItemsAsync(IssueName.Text, CreateLabels(), false).GetAwaiter().GetResult();
if (res == true)
CurrentStatus.Text = "Created Issue";
}
The actual creating code looks like:
static public async Task<bool> CreateItemsAsync(string issueName, string labels, bool createMergeRequest)
{
if (createMergeRequest == false)
{
string issueURL = "https://gitlabserver.tradinghub.com/api/v4/projects/9/issues/";
var stringContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("labels", labels),
new KeyValuePair<string, string>("title", issueName),
});
var response = await client.PostAsync(issueURL, stringContent);
}
}
However, this freezes at the PostAsync call. It creates the issue but never returns.
I saw on here:
Avoiding Deadlock with HttpClient
That this type of operation is not supported in WPF.
What would be the standard way of doing this in a VSDev extension?