I'm a newbie at building AddIns with the Pro SDK.
I have created an ArcGIS Pro AddIn button using VS2017 C#. I am trying to get a Windows Form (frmSAPAttributes) Listbox (lstAttributes) to populate with a parsed JSON string. The parsing works, and I can display each string individually in a messagebox.show(), but when I try to add the items to my Windows Form Listbox during runtime, and show the form, the form is empty and it just hangs in Pro. The following is the section of code:
protected async override void OnClick()
{
await QueuedTask.Run(() =>
{
// get the currently selected features in the map
var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
// get the first layer and its corresponding selected feature OIDs
var firstSelectionSet = selectedFeatures.First();
// create an instance of the inspector class
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// load the selected features into the inspector using a list of object IDs
inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value);
//get the value of
var pscode = inspector["SAP_ID"];
var SAPID = pscode.ToString();
var urlLink = "http://sappsprod.marinwater.local:8000/equi/" + SAPID;
// Create a request using a URL that can receive a post.
//MessageBox.Show(NewURL);
WebRequest request = WebRequest.Create(urlLink) as HttpWebRequest;
request.Credentials = CredentialCache.DefaultCredentials;
request.Method = "GET";
WebResponse response = request.GetResponse() as HttpWebResponse;
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
System.Windows.Forms.MessageBox.Show(responseFromServer);
JToken outer = JToken.Parse(responseFromServer);
JArray inner = outer["DATA"].Value<JArray>();
frmSAPAttributes form = new frmSAPAttributes();
string strSAPID = "SAPID : " + SAPID;
form.lstAttributes.BeginUpdate();
form.lstAttributes.Items.Add(strSAPID);
form.lstAttributes.EndUpdate();
form.Show();
Would someone please help me understand what's going on?
Thank You!