ArthurHub / ArthurHub/HTML-Renderer

System.OutOfMemoryException when using HTMLPanel on Multi-Thread Application

オープン
#73 コメント 0 件 リアクション 0 件 担当者 1 名 @Licshee が担当を希望しています GitHub で見る
bug enhancement
主要言語
C#
スター
1.4k
フォーク
550
平均マージ
14日 9時間
マージ済み PR(30日)
1

説明

Hello guys, right now I'm testing the **HTMLPanel** for my application and it must has **multiples threads** working together. But actually I'm getting the **System.OutOfMemoryException**.
After lots of tries and errors, I figure out memory isn't the problem. So here is what I got until now:

When creating a new thread executing the function Application.Run() with inline creation of Form's object, everything goes cool like this:

`(new Thread(() => Application.Run(new Form1()))).Start();`

the Form1 constructor only creates the HTMLPanel and render something:

```
public Form1()
{
InitializeComponent();

HtmlPanel Panel = new HtmlPanel();
Panel.Text = "

Hello World

This is html rendered text

";
Panel.Dock = DockStyle.Fill;
Controls.Add(Panel);
}
```

But when I first create the object and then I pass the object on a function, I get the error:

```
Form1 form = new Form1();
(new Thread(() => Application.Run(form))).Start();
```

Here is the full exception message:
`An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Drawing.dll`

I have no idea what's going on behind the scenes through the windows memory, and if someone's may help me, I will be really grateful. Thanks community, that's a powerful HTML tool for C#.

**EDIT:**
Well, some weeks ago I discovered the problem happens when trying to access the Panel from another thread, it's a common **Cross-Thread** exception but since the Panel is inside an form, the Debuger reports a different message.
I solved my problem for a while creating the Form inside the new thread like:

`(new Thread(() => CreateForm()).Start();`

Then:

```
CreateForm()
{
Application.Run(new Form1());
}
```

So if the HTML Renderer's developer sees this Issue, probably the problem it's located on **Multi-Thread** treatment.
I hope I help with something.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。