-
Jul 4th, 2022, 12:13 PM
#1
Thread Starter
Lively Member
Paint event nto being called - why?
I have a Windows form program that gets some XML data from the cloud (more on this below), processes in, then modifies the form to display the data (via the Paint event which makes sense and which should be triggered by my call to Me.Refresh). For debugging purposes, I included a line of code that dumps the XML to a file.
Here’s the problem: When I run the program and tell it to read the XML data from the file, the program runs just fine. However, when I tell the program to get the data from the cloud, the Paint event handler is never called. I know this because I put a break point in the function and the break point is never hit. However, a Paint event, for a PictureBox element, is being called properly via a Refresh command.
To get the XML data (simplified to remove error catching), my code looks like this:
Code:
Dim xmlDataClient As HttpClient = New HttpClient()
Dim siteURL As String = "<URL>"
Dim responseBody As String = ""
Dim response As HttpResponseMessage = Await xmlDataClient.GetAsync(siteURL)
response.EnsureSuccessStatusCode()
responseBody = Await response.Content.ReadAsStringAsync()
Since this is the only difference between the get versus read, I suspect that there is something happening here that I am not doing correctly. I suspect that the Await need to be 'stopped', but have no idea what do to. Interestingly, in an earlier version of the program, when the images were in PictureBox elements, this was not an issue.
-
Jul 4th, 2022, 03:40 PM
#2
Re: Paint event nto being called - why?
Does it need to be called async?
Try…
Code:
Dim wc As new Net.WebClient
Dim response as string = wc.DownLoadString(url)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 4th, 2022, 04:05 PM
#3
Thread Starter
Lively Member
Re: Paint event nto being called - why?
.paul. - Thanks. For some reason, when I first wrote this a year or so ago, I felt that the approach I had laid out was the proper one, and I had that stuff in a Try structure. I greatly simplified the code using your approach and it worked fine.
-
Jul 4th, 2022, 08:59 PM
#4
Re: Paint event nto being called - why?
Originally Posted by groston
I have a Windows form program that gets some XML data from the cloud (more on this below), processes in, then modifies the form to display the data (via the Paint event which makes sense and which should be triggered by my call to Me.Refresh).
And yet there's no Refresh call in the code you posted, so how are we supposed to determine what's wrong?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|