private async Task <T> OBSCommandTimeoutWrapper <T>(Func <T> function, int timeout = CommandTimeoutInMilliseconds)
        {
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            Task <T> task  = AsyncRunner.RunSyncAsAsync(function, cancellationTokenSource.Token);
            Task     delay = Task.Delay(timeout);
            await Task.WhenAny(new Task[] { task, delay });

            if (task.IsCompleted)
            {
                return(task.Result);
            }
            else
            {
                cancellationTokenSource.Cancel();
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                AsyncRunner.RunSyncAsAsync(() => this.OBSWebsocket_Disconnected(this, new EventArgs()), new CancellationToken());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                return(default(T));
            }
        }