I have added a custom menu to the grasshopper editor. I have done this by setting an event handler for GrasshopperInstances.CanvasCreated
in a custom PriorityLoad
.
I am calling an event to retrieve the release of a specific repository, to get the release I have to use an async Task, but when hits the await function the code froze.
here the code
public class MenuAssemblyPriority : GH_AssemblyPriority
{
// Above this method there is the code to define the menu into the GH canvas.
private void GetVersion(object sender, EventArgs e)
{
MessageBox.Show(Helper.GetReleaseVersion().Result);
}
}
The method GetReleaseVersion is into another project that is referenced.
public static class Helper
{
public static async Task<string> GetReleaseVersion()
{
var client = new GitHubClient(new ProductHeaderValue("Name"));
var releases = await client.Repository.Release.GetAll("owner", "repo");
return releases[0].TagName;
}
}
Thanks for the help.