Async aspx page
Imports System.Net.Http
Imports System.Threading.Tasks
Imports ClassLibrary1
Imports ClassLibrary1.libfuncs
Public Class LandAndPropertyReport
Inherits System.Web.UI.Page
Property getLandregistryPolygonsByLandregistryTitleNumberResponse As New getLandregistryPolygonsByLandregistryTitleNumberResponse
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'Lets stop on here. Build the report back end (using classlib funcs) sync first. Then async the funcs, then try it from here aspx async.
Dim stopWatch As New Stopwatch()
stopWatch.Start()
RegisterAsyncTask(New PageAsyncTask(Function() GetPWGsrvAsync(Context.Request("title_no"))))
stopWatch.Stop()
ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}", stopWatch.Elapsed.Milliseconds / 1000.0)
End Sub
Private Async Function GetPWGsrvAsync(title_no) As Task
Dim DemoImageTask = GetDemoImageTaskAsync()
Dim TitleSummaryTask = GetTitleSummaryAsync(title_no)
' Dim prodTask = GetProductsAsync()
' Dim gizmoTask = GetGizmosAsync()
' Await Task.WhenAll(widgetTask, prodTask, gizmoTask)
Await Task.WhenAll(DemoImageTask,TitleSummaryTask)
getLandregistryPolygonsByLandregistryTitleNumberResponse = TitleSummaryTask.Result
title_no.label =title_no
'title_class.label = getLandregistryPolygonsByLandregistryTitleNumberResponse.
Image1.Attributes("src") = "data:image/png;base64," & DemoImageTask.Result
' Dim pwgVM As New ProdGizWidgetVM(widgetTask.Result, prodTask.Result, gizmoTask.Result)
'WidgetGridView.DataSource = pwgVM.widgetList
'WidgetGridView.DataBind()
'ProductGridView.DataSource = pwgVM.prodList
'ProductGridView.DataBind()
'GizmoGridView.DataSource = pwgVM.gizmoList
'GizmoGridView.DataBind()
End Function
Private Async Function GetDemoImageTaskAsync() As Task(Of String)
Using client As New HttpClient()
Dim imageBytes As Byte() = Await client.GetByteArrayAsync("http://" & ClassLibrary1.systemConfig.imageServerUrl & "/styles/basic/static/-0.357300,50.815900,16/200x200.png?marker=-0.357300,50.815900|https://devpv1.landcycle.com/images/marker_styled.png")
Dim base64String As String = Convert.ToBase64String(imageBytes)
Return base64String
End Using
End Function
Private Async Function GetTitleSummaryAsync(title_no) As Task(Of getLandregistryPolygonsByLandregistryTitleNumberResponse)
dim getLandregistryPolygonsByLandregistryTitleNumberResponse = await libfuncs.getLandregistryPolygonsByLandregistryTitleNumberAsync(title_no)
Return getLandregistryPolygonsByLandregistryTitleNumberResponse
End Function
Private Function GetGizmosAsync() As Object
End Function
Private Function GetProductsAsync() As Object
End Function
End Class
<%@ Page Async="true" Language="vb" AutoEventWireup="true" CodeBehind="LandAndPropertyReport.aspx.vb" Inherits="Website.LandAndPropertyReport" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" />
<p> Title Number: <asp:Label ID="title_no" runat="server" Text="Label"></asp:Label> </p>
<asp:Label ID="ElapsedTimeLabel" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Comments
Post a Comment