mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-07 22:50:44 +00:00
Replaced Control.Invoke() by Control.BeginInvoke() to avoid deadlock when Debug.Print() is called from the finalizing thread.
This commit is contained in:
parent
76641d46d6
commit
a2c0cd8b30
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
public class TextBoxTraceListener : TraceListener
|
public class TextBoxTraceListener : TraceListener
|
||||||
{
|
{
|
||||||
private TextBox _target;
|
TextBox _target;
|
||||||
private StringSendDelegate _invokeWrite;
|
StringSendDelegate _invokeWrite;
|
||||||
|
|
||||||
public TextBoxTraceListener(TextBox target)
|
public TextBoxTraceListener(TextBox target)
|
||||||
{
|
{
|
||||||
|
@ -20,13 +21,13 @@ namespace Examples
|
||||||
public override void Write(string message)
|
public override void Write(string message)
|
||||||
{
|
{
|
||||||
if (_target.Created)
|
if (_target.Created)
|
||||||
_target.Invoke(_invokeWrite, new object[] { message });
|
_target.BeginInvoke(_invokeWrite, new object[] { message });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void WriteLine(string message)
|
public override void WriteLine(string message)
|
||||||
{
|
{
|
||||||
if (_target.Created)
|
if (_target.Created)
|
||||||
_target.Invoke(_invokeWrite, new object[] { message + Environment.NewLine });
|
_target.BeginInvoke(_invokeWrite, new object[] { message + Environment.NewLine });
|
||||||
}
|
}
|
||||||
|
|
||||||
private delegate void StringSendDelegate(string message);
|
private delegate void StringSendDelegate(string message);
|
||||||
|
|
Loading…
Reference in a new issue