Results 1 to 4 of 4

Thread: Paint event nto being called - why?

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    71

    Question 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.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    24,908

    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)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    71

    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.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    108,871

    Re: Paint event nto being called - why?

    Quote Originally Posted by groston View Post
    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
  •  



Click Here to Expand Forum to Full Width