git - libgit2sharp Repository "safe handle has been closed" -


is there problem instantiating repository object twice in same method, each time wrapped in separate using() statement :

using(var repo = new repository({local-path}, new repositoryoptions()) { // stuff repo }  // other stuff not related repo  using(var repo = new repository({local-path}, new repositoryoptions()) { // more stuff repo } 

for such code-block structure, in do more stuff block i'm experiencing run-time exception safe handle has been closed.

is there problem instantiating repository object twice in same method, each time wrapped in separate using() statement

instantiating repository instance quite cheap, there's no problem approach.

however, 1 has keep in mind following things

  • objects (references, commits, trees, ..) returned through libgit2sharp library expected used during lifetime of repository (ie. before it's disposed). not doing may lead objectdisposedexception being thrown.

  • for performance reasons, libgit2, underlying native library lot of caching. cache purged every time repository disposed. such, relying on different instances of repository type, may prevent 1 benefiting performance bumps.

i'm experiencing run-time exception safe handle has been closed.

this may happen if reuse in second using block objects originate first one.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -