Skip to content

Commit

Permalink
Merge pull request #78 from YoshihiroIto/master
Browse files Browse the repository at this point in the history
lock listeners
  • Loading branch information
danipen authored Dec 13, 2024
2 parents 0b99f35 + 22d2b04 commit 1d139b0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/TextMateSharp/Model/TMModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ public void RemoveModelTokensChangedListener(IModelTokensChangedListener listene

public void Dispose()
{
listeners.Clear();
lock (listeners)
{
listeners.Clear();
}

Stop();
GetLines().Dispose();
}
Expand Down Expand Up @@ -375,15 +379,18 @@ private void BuildEventWithCallback(Action<ModelTokensChangedEventBuilder> callb

private void Emit(ModelTokensChangedEvent e)
{
foreach (IModelTokensChangedListener listener in listeners)
lock (listeners)
{
try
{
listener.ModelTokensChanged(e);
}
catch (Exception ex)
foreach (IModelTokensChangedListener listener in listeners)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
try
{
listener.ModelTokensChanged(e);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
}
}
Expand Down

0 comments on commit 1d139b0

Please sign in to comment.