Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MarkdownTextBlock not working in multithreaded window

未关闭
#776 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp
领域
desktop, frontend

调研方向

通过打开两个线程窗口,根据链接的 UWP 或 WAS SettingsPage 示例复现该问题。从 MarkdownTextBlock.OnApplyTemplate 和 Build/ApplyText 开始,然后沿着 heading 路径跟踪到 MyHeading.SetHProperties,此处会发生 COMException。当 MarkdownTextBlock 在两个窗口中都能成功渲染且不出现线程异常时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug :bug:
Describe the bug

MarkdownTextBlock not working in multithreaded window both in UWP and WAS.

System.Runtime.InteropServices.COMException (0x8001010E)
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
   at ABI.Windows.UI.Xaml.Documents.ITextElementMethods.set_Foreground(IObjectReference _obj, Brush value)
   at Windows.UI.Xaml.Documents.TextElement.set_Foreground(Brush value)
   at CommunityToolkit.WinUI.Controls.TextElements.MyHeading.SetHProperties(Int32 level)
   at CommunityToolkit.WinUI.Controls.TextElements.MyHeading..ctor(HeadingBlock headingBlock, MarkdownConfig config)
   at CommunityToolkit.WinUI.Controls.Renderers.ObjectRenderers.HeadingRenderer.Write(WinUIRenderer renderer, HeadingBlock obj)
   at Markdig.Renderers.MarkdownObjectRenderer`2.Write(RendererBase renderer, MarkdownObject obj)
   at Markdig.Renderers.RendererBase.Write(MarkdownObject obj)
   at Markdig.Renderers.RendererBase.WriteChildren(ContainerBlock containerBlock)
   at Markdig.Renderers.RendererBase.Write(MarkdownObject obj)
   at CommunityToolkit.WinUI.Controls.Renderers.WinUIRenderer.Render(MarkdownObject markdownObject)
   at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.ApplyText(Boolean rerender)
   at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.Build()
   at CommunityToolkit.WinUI.Controls.MarkdownTextBlock.OnApplyTemplate()
   at Windows.UI.Xaml.FrameworkElement.Windows.UI.Xaml.IFrameworkElementOverrides.OnApplyTemplate()
   at ABI.Windows.UI.Xaml.IFrameworkElementOverrides.Do_Abi_OnApplyTemplate_2(IntPtr thisPtr)
Steps to reproduce
1. Use it such as [UWP](https://github.com/wherewhere/CoreAppUWP/blob/wuxc/CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml#L395-L402) or [WAS](https://github.com/wherewhere/CoreAppUWP/blob/muxc/CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml#L419-L426)
2. Run it and open two different thread windows.
3. It broken.
Expected behavior

Works fine.

Screenshots

Image

Code Platform
  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK
Windows Build Number
  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)
Other Windows Build number

26200.7623

App minimum and target SDK version
  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)
Other SDK version

No response

Visual Studio Version

Preview

Visual Studio Build Number

Insiders [11408.92]

Device form factor

Desktop

Additional context

This problem is exits since the control is here. I don't know if here already has a issue.

Help us help you

Yes, I'd like to be assigned to work on this item.

主要语言
C#
星标
483
派生
89
平均合并
4 天 5 小时
30 天内合并 PR
2

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CommunityToolkit/Labs-Windows 的其他 Issue

查看 CommunityToolkit/Labs-Windows 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。