Skip to content

Commit

Permalink
hooks are back to running the callbacks in another thread to prevent …
Browse files Browse the repository at this point in the history
…any weird shit from happening on the hook
  • Loading branch information
xenolightning committed Mar 1, 2016
1 parent e89d4e3 commit ecede9a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions AudioSwitcher.AudioApi.Hooking/RemoteInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public bool HookInstalled()
{
Interlocked.Increment(ref _messageCount);

if (_hookInstalled != null)
_hookInstalled();
ThreadPool.QueueUserWorkItem(x =>
{
if (_hookInstalled != null)
_hookInstalled();
});

return true;
}
Expand All @@ -58,15 +61,22 @@ public void HookUninstalled(int processId)
{
Interlocked.Increment(ref _messageCount);

if (_hookUninstalled != null)
_hookUninstalled(processId);
ThreadPool.QueueUserWorkItem(x =>
{
if (_hookUninstalled != null)
_hookUninstalled(processId);
});
}

public void ReportError(int processId, Exception e)
{
Interlocked.Increment(ref _messageCount);
if (_errorHandler != null)
_errorHandler(processId, e);

ThreadPool.QueueUserWorkItem(x =>
{
if (_errorHandler != null)
_errorHandler(processId, e);
});
}

public string GetDefaultDevice(DataFlow dataFlow, Role role)
Expand Down

0 comments on commit ecede9a

Please sign in to comment.