Skip to content

Commit

Permalink
Fix some UnobservedTaskException errors
Browse files Browse the repository at this point in the history
Removed method which was not called anymore. Added override method which handles the StateMaanger.Exited use case explicitly.
  • Loading branch information
Chris-Dev-GH authored Dec 20, 2021
1 parent e83a4ac commit aa5fb43
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/PuppeteerSharp/States/DisposedState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@ public DisposedState(StateManager stateManager) : base(stateManager)
{
}

public void EnterFrom(LauncherBase p, State fromState)
public override Task EnterFromAsync(LauncherBase p, State fromState, TimeSpan timeSpan)
{
if (!StateManager.TryEnter(p, fromState, this))
if (fromState == StateManager.Exited)
{
// Delegate Dispose to current state, because it has already changed since
// transition to this state was initiated.
StateManager.CurrentState.Dispose(p);
return null;
}
else if (fromState != StateManager.Exited)
{
Kill(p);

p.ExitCompletionSource.TrySetException(new ObjectDisposedException(p.ToString()));
p.TempUserDataDir?.Dispose();
}
Kill(p);

p.ExitCompletionSource.TrySetException(new ObjectDisposedException(p.ToString()));
p.TempUserDataDir?.Dispose();

return null;
}

public override Task StartAsync(LauncherBase p) => throw new ObjectDisposedException(p.ToString());
Expand Down

0 comments on commit aa5fb43

Please sign in to comment.