Skip to content

Commit 6e58823

Browse files
Glue Blazor demo - GlazorWebAssembly - update
1 parent 9a90e65 commit 6e58823

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

glazor/GlazorWebAssembly/GlazorWebAssembly/AspNetDispatcher.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Threading.Tasks;
3-
using Glue.AppManager;
3+
using Glue;
44
using Microsoft.AspNetCore.Components;
55

66
namespace GlazorWebAssembly
@@ -19,21 +19,32 @@ public Task<T> InvokeAsync<T>(Func<T> callback)
1919
return dispatcher_.InvokeAsync(callback);
2020
}
2121

22-
public void BeginInvoke(Action action)
22+
public void Dispatch(Func<Task> taskAction)
2323
{
24-
dispatcher_.InvokeAsync(action);
24+
dispatcher_.InvokeAsync(taskAction);
2525
}
2626

2727
public T Invoke<T>(Func<T> action)
2828
{
2929
return dispatcher_.InvokeAsync(action).Result;
3030
}
3131

32-
public void Invoke(Action action)
32+
public void EnsureStarted()
33+
{
34+
}
35+
36+
public void Dispatch(Action action)
3337
{
3438
dispatcher_.InvokeAsync(action);
3539
}
3640

3741
public int DispatcherThreadId => -1;
42+
43+
public string Name => dispatcher_.ToString();
44+
45+
public void Dispose()
46+
{
47+
// TODO release managed resources here
48+
}
3849
}
3950
}

glazor/GlazorWebAssembly/GlazorWebAssembly/GlazorWebAssembly.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="GlueBase" Version="0.0.18" />
12+
<PackageReference Include="GlueBase" Version="0.0.45" />
1313
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.11" />
1414
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.11" PrivateAssets="all" />
1515
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />

glazor/GlazorWebAssembly/GlazorWebAssembly/GlueProvider.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,17 @@ private async Task<string> GetPromptInput(string promptId)
143143
return input;
144144
}
145145

146-
private Task<IGlueWindow> RegisterMainWindow(IGlue42Base glue, string windowId)
146+
private async Task<IGlueWindow> RegisterMainWindow(IGlue42Base glue, string windowId)
147147
{
148148
// create dispatcher for the hosted window
149149
IGlueDispatcher dispatcher = CreateGlueDispatcher(Dispatcher.CreateDefault());
150150

151151
// get a dummy window factory that is for hosted windows
152-
var glueWindowFactory = glue.GetWindowFactory(new HostedWindowFactoryBridge<object>(dispatcher));
152+
var glueWindowFactory = await glue.GetWindowFactory(new HostedWindowFactoryBridge<object>(dispatcher)).ConfigureAwait(false);
153153

154154
//obtain the main window
155-
return glueWindowFactory.RegisterStartupWindow(this, "Glazor Web Assembly",
156-
builder => builder.WithId(windowId).WithChannelSupport(true));
155+
return await glueWindowFactory.RegisterStartupWindow(this, "Glazor Web Assembly",
156+
builder => builder.WithId(windowId).WithChannelSupport(true)).ConfigureAwait(false);
157157
}
158158

159159
private IGlueDispatcher CreateGlueDispatcher(Dispatcher dispatcher)

glazor/GlazorWebAssembly/GlazorWebAssembly/Pages/Glue42.razor

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129

130130
public object GetPropertyValue(string property)
131131
{
132-
return values_[Header.IndexOf(property, 0, Header.Length)];
132+
int indexOf = Header.IndexOf(property, 0, Header.Length);
133+
return values_[indexOf];
133134
}
134135
}
135136

0 commit comments

Comments
 (0)