private bool Initialize(IConnectionEventSink sink) { this.sink = sink; QtVsToolsPackage.Instance.JoinableTaskFactory.Run(async() => { await Task.WhenAny(new[] { // Try to start client thread // Unblock if thread was abruptly terminated (e.g. DLL not found) clientThread = Task.Run(() => ClientThread()), // Unblock if client was created (i.e. client thread is running) Task.Run(() => clientCreated.WaitOne()) }); }); if (State == DebugClientState.Unavailable) { // Client thread did not start clientCreated.Set(); Dispose(); return(false); } return(true); }
public static DebugClient Create(IConnectionEventSink sink) { var _this = new DebugClient(); return(_this.Initialize(sink) ? _this : null); }