Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Fixed: Race condition on dispose that triggers AccessViolationException and kills the process #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Nickvision.MPVSharp/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Nickvision.MPVSharp;
public class Client : MPVClient, IDisposable
{
private bool _disposed;
private bool _isDisposing;

public event EventHandler<LogMessageReceivedEventArgs>? LogMessageReceived;
public event EventHandler<GetPropertyReplyReceivedEventArgs>? GetPropertyReplyReceived;
Expand Down Expand Up @@ -64,6 +65,7 @@ protected virtual void Dispose(bool disposing)
}
if (disposing)
{
_isDisposing = true;
Destroy();
}
_disposed = true;
Expand Down Expand Up @@ -144,9 +146,9 @@ protected virtual void Dispose(bool disposing)
/// </summary>
private void HandleEvents()
{
while (!_disposed)
while (!_disposed && !_isDisposing)
{
var clientEvent = WaitEvent(0);
var clientEvent = WaitEvent(-1);
switch (clientEvent.Id)
{
case MPVEventId.Shutdown:
Expand Down