• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DemoBytom / DemoEngine / 13123725757

03 Feb 2025 10:03PM UTC coverage: 10.779% (-0.8%) from 11.563%
13123725757

push

coveralls.net

DemoBytom
Fixing winforms deadlocks

an await operation must return to the thread it was spawned on, because due to using winforms the main thread must be SDA.
But because the windows messages are handled by a loop, and that loop had a async operation - the message to switch back to main thread deadlocks

227 of 2106 relevant lines covered (10.78%)

24786.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Demo.Engine/Program.cs
1
// Copyright © Michał Dembski and contributors.
2
// Distributed under MIT license. See LICENSE file in the root for more information.
3

4
using Autofac.Extensions.DependencyInjection;
5
using Demo.Engine.Core;
6
using Demo.Engine.Core.Components.Keyboard.Internal;
7
using Demo.Engine.Core.Extensions;
8
using Demo.Engine.Core.Interfaces.Platform;
9
using Demo.Engine.Core.Interfaces.Rendering.Shaders;
10
using Demo.Engine.Core.Models.Options;
11
using Demo.Engine.Extensions;
12
using Demo.Engine.Platform.DirectX12;
13
using Demo.Engine.Platform.Windows;
14
using Demo.Engine.Windows.Platform.Netstandard.Win32;
15
using Microsoft.Extensions.DependencyInjection;
16
using Microsoft.Extensions.Hosting;
17
using Serilog;
18

19
try
20
{
21
    var hostBuilder = new HostBuilder()
×
22
        .CreateDefault(args)
×
23
        .WithSerilog()
×
24
        .UseServiceProviderFactory(new AutofacServiceProviderFactory())
×
25
        .ConfigureServices((hostContext, services)
×
26
        =>
×
27
        {
×
28
            _ = services
×
29
            //.AddHostedService<EngineService>()
×
30
            .Configure<RenderSettings>(hostContext.Configuration.GetSection(nameof(RenderSettings)))
×
31
            //DirectX 11
×
32
            //.AddScoped<
×
33
            //    ID3D11RenderingEngine,
×
34
            //    IRenderingEngine,
×
35
            //    D3D11RenderingEngine>()
×
36
            //.AddScoped<
×
37
            //    ID3D12RenderingEngine,
×
38
            //    IRenderingEngine,
×
39
            //    D3D12RenderingEngine>()
×
40
            /*** Windows Only ***/
×
41
            .AddScoped<IRenderingControl, RenderingForm>()
×
42
            .AddScoped<IOSMessageHandler, WindowsMessagesHandler>()
×
43
            .AddEngineCore()
×
44
            //.AddTransient<IShaderCompiler, Demo.Engine.Platform.DirectX12.Shaders.ShaderCompiler>()
×
45
            //.AddSingleton<IDebugLayerLogger, DebugLayerLogger>()
×
46
            .AddDirectX12()
×
47
            //tmp
×
48
            //.AddTransient<ICube, Cube>()
×
49
            /*** End Windows Only ***/
×
50
            .AddMediatR(config
×
51
                => config.RegisterServicesFromAssemblyContaining<KeyboardHandler>());
×
52

×
53
            _ = services.AddOptions();
×
54

×
55
            _ = services
×
56
                .AddSingleton(x =>
×
57
                    new Demo.Engine.Platform.DirectX12.Shaders.CompiledVS("Shaders/Triangle/TriangleVS.hlsl", x.GetRequiredService<IShaderCompiler>()))
×
58
                .AddSingleton(x =>
×
59
                    new Demo.Engine.Platform.DirectX12.Shaders.CompiledPS("Shaders/Triangle/TrianglePS.hlsl", x.GetRequiredService<IShaderCompiler>()));
×
60
        })
×
61
        //.ConfigureContainer<ContainerBuilder>(builder
×
62
        //    => builder
×
63
        //        .RegisterType<Cube>()
×
64
        //        .As<ICube>()
×
65
        //        .ExternallyOwned())
×
66
        ;
×
67

68
    var host = hostBuilder.Build();
×
69

70
    await host.RunAsync();
×
71
}
×
72
catch (Exception ex)
73
{
74
    //log fatal
75
    Log.Fatal(ex, "FATAL ERROR!");
×
76
    return -1;
×
77
}
78
finally
79
{
80
    Log.CloseAndFlush();
×
81
}
82

83
return 0;
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc