This project is read-only.

ObjectDisposedException from HttpClient (TimeoutCallBack)

Topics: Web Api
Nov 28, 2011 at 9:48 AM


I'm getting an ObjectDisposedException being thrown by the HttpClient when it calls its static TimeoutCallBack method to cancel a CancellationTokenSource created during a successful request.
It appear this timeout is set from within HttpClient.Send(...) via SetTimeout(linkedCts);

Is this accepted behaviour or is there something I am not cleaning up after a successful request?

I am using a single HttpClient instance for multiple requests during the lifetime of my client app (ClientSession).
I do not recreate the client on each call.
I am using the default timeout.

Thanks for any help in advance.

Dec 6, 2011 at 11:29 AM


No one getting ObjectDisposedException exceptions thrown by HttpClient!?

Dec 6, 2011 at 9:22 PM

We think this is a bug when running on .NET 4, where disposing CancellationTokenSource twice results in an ObjectDisposedException.

Could you please open an issue in the IssueTracker with a simple project that reproduces the issue?

Daniel Roth

Dec 7, 2011 at 10:40 AM

Thanks Dan,  Will raise issue with repro shortly.

Dec 12, 2011 at 1:12 PM

Hi Dan,

The problem has gone away in Preview 6 - thanks.

The handling of the timeoutTimer is now being disposed once the request is completed for NET_4 in P6.