# DiagnosticEventCollector.WaitForEventAsync(string, TimeSpan, CancellationToken)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.diagnostics.diagnosticeventcollector/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.diagnostics.diagnosticeventcollector/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/Diagnostics/DiagnosticEventCollector.cs)

```csharp
public Task<DiagnosticEvent> WaitForEventAsync(string eventName, TimeSpan timeout, CancellationToken cancellationToken = default(CancellationToken))
```

Waits for an event with the specified name to be captured. If an event with that name has already been captured, returns immediately.

### Parameters

- `eventName` (`string`): The name of the event to wait for.
- `timeout` (`TimeSpan`): The maximum time to wait.
- `cancellationToken` (`CancellationToken`): A cancellation token.

### Returns

The captured event.

### Exceptions

- `System.TimeoutException`: Thrown if the event is not captured within the timeout.
