Skip to content

Commit

Permalink
Added ability to set name of thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
DJGosnell committed Oct 14, 2022
1 parent 0096797 commit bc68c80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DtronixCommon/DtronixCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.6.2.0</Version>
<Version>0.6.3.0</Version>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<Company>Dtronix</Company>
Expand Down
13 changes: 12 additions & 1 deletion src/DtronixCommon/Threading/SingleActionThreadExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SingleActionThreadExecutor : IDisposable
internal Thread? Thread;

private readonly Action _action;
private readonly string _name;

/// <summary>
/// True if the thread dispatcher has started.
Expand Down Expand Up @@ -43,8 +44,17 @@ public class SingleActionThreadExecutor : IDisposable
/// Creates a new single action dispatcher.
/// </summary>
public SingleActionThreadExecutor(Action action)
:this(action, "SingleActionThreadExecutor")
{
}

/// <summary>
/// Creates a named single action dispatcher.
/// </summary>
public SingleActionThreadExecutor(Action action, string name)
{
_action = action;
_name = name;
_resetEvent = new ManualResetEventSlim(false);
}

Expand Down Expand Up @@ -114,7 +124,8 @@ public void Start()

Thread = new Thread(Pump)
{
IsBackground = true
IsBackground = true,
Name = _name
};

Thread.Start();
Expand Down

0 comments on commit bc68c80

Please sign in to comment.