question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for IDisposable?

See original GitHub issue

Your example code:

public interface IGitHubApi
{
  [Get("users/{userId}")]
  Task<User> GetUserAsync([Path] string userId);
}

IGitHubApi api = RestClient.For<IGitHubApi>("https://api.github.com");
User user = await api.GetUserAsync("canton7");

If I want to dispose the RestClient after use, is this possible like:

public interface IGitHubApi : IDisposable
{
  [Get("users/{userId}")]
  Task<User> GetUserAsync([Path] string userId);
}

using (IGitHubApi api = RestClient.For<IGitHubApi>("https://api.github.com"))
{
  User user = await api.GetUserAsync("canton7");
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
canton7commented, May 12, 2017
0reactions
StefHcommented, May 15, 2017

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IDisposable Interface (System)
Documentation for types that implement IDisposable note that fact and include a reminder to call its Dispose implementation. The C#, F#, and Visual...
Read more >
c# - Implementing IDisposable (the Disposable Pattern) as ...
My implementation. So, here is the solution I came up with. public class DisposeService<T> where T : IDisposable { private readonly T ...
Read more >
How to use IDisposable in ASP.NET Core
The simplest way to dispose an IDisposable instance is by using the “using” statement, which calls the Dispose method on the instance ...
Read more >
All about IDisposable
All classes that support disposing extend IDisposable interface. // unmanaged resources. It's a primitive one defining only one method –  ...
Read more >
Support IDisposable for Function Handlers · Issue #342
I considered using a destructor, but believe the shared contract of IDisposable is a better solution overall.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found