Skip to content

Commit c935d31

Browse files
authored
Merge pull request #32 from alex-oswald/change-sample
Update .NET
2 parents f094cf9 + a2d4bad commit c935d31

16 files changed

+170
-122
lines changed

TestWindowsFormsLifetime.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ variables:
1515

1616
steps:
1717
- task: UseDotNet@2
18-
displayName: 'Use .NET 8.x SDK'
18+
displayName: 'Use .NET 9.x SDK'
1919
inputs:
20-
version: 8.x
20+
version: 9.x
2121

2222
- task: DotNetCoreCLI@2
2323
displayName: 'Restore Solution'

samples/AppContext/AppContext.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0-windows</TargetFramework>
5+
<TargetFramework>net9.0-windows</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
77
<IsPackable>false</IsPackable>
88
<Nullable>enable</Nullable>

samples/BlazorHybrid/BlazorHybrid.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net8.0-windows</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
66
<Nullable>enable</Nullable>
77
<UseWindowsForms>true</UseWindowsForms>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.WindowsForms" Version="7.0.49" />
14-
<PackageReference Include="MudBlazor" Version="6.1.2" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.WindowsForms" Version="9.0.40" />
14+
<PackageReference Include="MudBlazor" Version="8.2.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

samples/SampleApp/Form1.Designer.cs

Lines changed: 46 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/SampleApp/Form1.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ public partial class Form1 : Form
88
private readonly ILogger<Form1> _logger;
99
private readonly IFormProvider _formProvider;
1010

11-
public Form1(ILogger<Form1> logger, IFormProvider formProvider)
11+
public Form1(
12+
ILogger<Form1> logger,
13+
IFormProvider formProvider,
14+
TickBag tickBag)
1215
{
1316
InitializeComponent();
1417
_logger = logger;
1518
_formProvider = formProvider;
19+
tickBag.OnTick += TickBag_OnTick;
1620

17-
ThreadLabel.Text = $"{Thread.CurrentThread.ManagedThreadId} {Thread.CurrentThread.Name}";
21+
ThreadLabel.Text = $"Thread id = {Environment.CurrentManagedThreadId}, Thread name = {Thread.CurrentThread.Name}";
22+
TickLabel.Text = $"Tick = {tickBag.CurrentTick}";
23+
}
24+
25+
private void TickBag_OnTick(object? sender, int e)
26+
{
27+
TickLabel.Text = $"Tick: {e}";
1828
}
1929

2030
private async void button1_Click(object sender, EventArgs e)

samples/SampleApp/Form1.resx

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
1-
<root>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
262
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
464
<xsd:element name="root" msdata:IsDataSet="true">

samples/SampleApp/Form2.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ private void button1_Click(object sender, EventArgs e)
2727
Task.Run(() =>
2828
{
2929
_logger.LogInformation($"Task.Run Thread {Thread.CurrentThread.ManagedThreadId} {Thread.CurrentThread.Name}");
30-
_guiContext.Invoke(new Action(() =>
30+
_guiContext.Invoke(new Action(async () =>
3131
{
32+
await Task.Delay(1000);
3233
_logger.LogInformation($"GuiContext Thread {Thread.CurrentThread.ManagedThreadId} {Thread.CurrentThread.Name}");
3334
button1.Text = new Random().Next(1, 10).ToString();
3435
}));

samples/SampleApp/FormSpawnHostedService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2626
while (!stoppingToken.IsCancellationRequested)
2727
{
2828
await Task.Delay(5000, stoppingToken);
29-
if (count < 5)
29+
if (count < 2)
3030
{
3131
// Fetch the form here using IFormProvider
3232
// The form provider will get the form from the DI container on the gui thread

samples/SampleApp/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
builder.Services.AddHostedService<FormSpawnHostedService>();
99
builder.Services.AddHostedService<TickingHostedService>();
1010
builder.Services.AddTransient<Form2>();
11+
builder.Services.AddSingleton<TickBag>();
1112

1213
var app = builder.Build();
1314
app.Run();

samples/SampleApp/SampleApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0-windows</TargetFramework>
4+
<TargetFramework>net9.0-windows</TargetFramework>
55
<UseWindowsForms>true</UseWindowsForms>
66
<IsPackable>false</IsPackable>
77
<Nullable>enable</Nullable>

0 commit comments

Comments
 (0)