Executing an asynchronous method from the dispose event

312 Views Asked by At

In my unit/integration tests (xUnit.net) I need to run some cleanup code that will remove some resources that may have been created. I'd like to do this only once. DeleteBucket is an async method. What are my options? Is there a "pre-dispose" event?

public void Dispose()
{
    var api = new AwsApi(creds, stdout);
    var success = await api.DeleteBucket(bucket, new CancellationTokenSource());
}
0

There are 0 best solutions below