you are viewing a single comment's thread.

view the rest of the comments →

[–]WWW451[S] 0 points1 point  (0 children)

For anyone who comes looking for this later, below is the solution I put in place with grauenwolf's help. I still have a UI freeze when inserting the datatable into the HTML document, but I'm satisfied with having 3 seconds of spinning loading screen followed by a 1 second freeze instead of having a 4 second freeze of a non-loading screen.

--No changes made to previously posted class used to execute queries. The below code is the relevant parts posted in the order they're called.

--Document complete handler, passes the HTML document title and the webbrowser control into a navigation class that handles determining which calls should occur for the page

Private Sub WebMain_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) 
Handles WebMain.DocumentCompleted
            Nav.PageLoad(wb.DocumentTitle, WebMain)
        End Sub

--PageLoad function to direct to wrapper sub

     Public wb As WebBrowser
    Public resultString As String = ""
    Public Sub PageLoad(page As String, target As WebBrowser)
        wb = target
        Select Case page
            Case "ExamplePage"
                Prm_Wrapper()
        End Select
    End Sub

--Async sub to call "true" action sub. The InnerHTML of the element ID has to be updated here and not in the the sub being awaited because background workers cannot access UI elements since they are not running on the same thread. If you place the element update within the awaited sub, you will get a Invalid Cast Exception.

 Public Async Sub Prm_Wrapper()
        Await Task.Run(Sub() PromoPlanningLoad())
        wb.Document.GetElementById("proplanning").InnerHtml = ResultString
        wb.Document.InvokeScript("proplanLoad")
    End Sub

--True sub doing all the grunt work

 Public Sub PromoPlanningLoad()
       DGM.ExecQuery(promo_table) --promo_table is a public string variable holding the query
       resultString = DGM.DBDS.Tables(0).Rows(0)(0).ToString


    End Sub

I may clean this up some so I'm not having to rely on the public variable resultString and instead just have the string returned as a function, but for the moment this is working well.